-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
..\../boost/type_traits/is_signed.hpp: In instantiation of 'const no_cv_t boost::detail::is_signed_values<test::enum1>::minus_one':
..\../boost/type_traits/is_signed.hpp:45:4: required from 'const bool boost::detail::is_signed_helper<test::enum1>::value'
..\../boost/type_traits/is_signed.hpp:74:4: required from 'const bool boost::detail::is_signed_impl<test::enum1>::value'
..\../boost/type_traits/is_signed.hpp:79:27: required from 'struct boost::is_signed<test::enum1>'
..\../boost/container_hash/hash.hpp:178:135: required from 'typename boost::enable_if_<boost::is_enum<T>::value, long unsigned int>::type boost::hash_value(T) [with T = test::enum1; typename boost::enable_if_<boost::is_enum<T>::value, long unsigned int>::type = long unsigned int]'
..\../boost/container_hash/hash.hpp:672:30: required from 'std::size_t boost::hash<T>::operator()(const T&) const [with T = test::enum1; std::size_t = long unsigned int]'
test\hash_enum_test.cpp:39:5: required from here
..\../boost/type_traits/is_signed.hpp:37:59: error: the result of the conversion is unspecified because '-1' is outside the range of type 'boost::detail::is_signed_values<test::enum1>::no_cv_t' {aka 'test::enum1'} [-Werror=conversion]
37 | static const no_cv_t minus_one = (static_cast<no_cv_t>(-1));
| ^~
The warning is correct, because -1 is not necessarily a valid value for enumeration types, so this is not required to work.
I'm not sure how we can fix this. I tried a few things, but nothing worked.
is_signed is not particularly useful for enums, and in fact std::is_signed doesn't support them, so this may seem of low priority; but what I'm actually trying to implement is underlying_type, and its C++03 implementation is
conditional<is_signed<T>, make_signed<T>, make_unsigned<T>>::type::type
Maybe what we actually need is just boost::underlying_type. (Or boost::underlying_type_, because Core has already - and incorrectly - claimed boost::underlying_type in boost/core/scoped_enum.hpp.)
Metadata
Metadata
Assignees
Labels
No labels