Hello John,
you have probably already read that I think some new TypeTraits are useful. Here are the details:
a) very useful: precise type classification - this is the basis of every abstraction and should definitely be implemented
- is_character: contains only characters (char32/16/8_t, wchar_t, char); is_un/signed_character
- is_integer: contains only integers and no characters and no bool (u/int8..X_t); is_un/signed_integer
- is_logic: contains only logical types (bool and boost::tribool, *))
- is_string: contains everything that can be used as a string, but needs these specializations:
1) is_bounded_string (similar to is_bounded_array)
2) is_unbounded_string (similar to is_unbounded_array)
3) is_static_string (for boost::basic_static_string)
4) is_string_ref (for boost::basic_string ref)
5) is_string_view (for std::basic_string_view)
6) is_string_class (for std::basic_string)
- character_of: the underlying character type based on is_string
b) very useful
- remove_cv_ptr (similar to remove_cv_ref)
- make_same_signed (similar to make_un/signed): changes the sign depending on a type
- conditional_signed: changes the sign depending on a truth value
- is_same_signed: same sign
c) also makes sense
- is_tuple
- is_rational (similar to boost::is_complex)
- is_binary: if base==2 (numeric_limits::radix==2)
- is_decimal: if base==10 (numeric_limits::radix==10)
d)
- is_native: a type is natively available on the platform (e.g. int64_t: Linux32:false, Linux64:true; float80_t: x86:true, else:false)
- is_vectorisable: a type can be vectorized natively on the platform - there are basic SSE/AVX/SVE/... functions
However, I have a problem: boost/std::is_integral contain bool. Perhaps you can do that like this, but it leads to problems with is_arithmetic, since is_arithmetic is based on is_integral and thus contains bool. I think the point of is_arithmetic is to be able to calculate numerically with the type - so the scenarios are not useful: abs(bool), sin/cos/...(bool), etc. The same applies to characters.
There are two possible solutions:
- redefine is_arithmetic -> is_integer || is_floating_point
- a new TypeTrait is_numeric (e.g.) -> is_integer || is_floating_point
There are some differences between boost- and std-TypeTraits. Can you please include that in the documentation?
Furthermore there seem to be errors with char8_t, e.g. boost::is_unsigned
participants (1)
-
Gero Peterhoff