-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Describe the enhancement requested
We have a large number of type traits in type_traits.h which are used inconsistently and whose relationships and specific semantics are not really documented. These have been added ad-hoc as they were needed rather than systematically laid out. I think instead of trying to construct them in reflection the class hierarchy of DataType is only indirectly useful; what we actually use these to check for is
- can I visit the slots of an array of this DataType?
- can those slots be represented as a
std::string_viewor are they numeric? - does an array of this type have an offsets buffer, and if so what is its type?
So I think it'd be more valuable to replace ambiguous traits like is_binary_like and is_string_like altogether, perhaps with is_string_view_visitable and is_utf8.
Nice to haves:
At the same time, traits like is_floating_type could be upgraded to c++17 variable templates. These are partially specializable as with class templates, so we wouldn't lose any flexibility by rewriting to:
namespace traits {
template <typename T>
constexpr bool is_floating_point = std::is_base_of_v<FloatingPointType, T>;
} // namespace traitsIt'd also be nice to unify the template traits with the function traits (which taking a Type::type or a const DataType& and return bool), so that where one is available the other is definitely present (similar to the way enable_if specializations are currently always present).
The enable_if specializations are handy but could be replaced by if constexpr in many places.
Component(s)
C++