diff options
Diffstat (limited to 'boost/multiprecision/traits/is_byte_container.hpp')
-rw-r--r-- | boost/multiprecision/traits/is_byte_container.hpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/boost/multiprecision/traits/is_byte_container.hpp b/boost/multiprecision/traits/is_byte_container.hpp index d97428f0f2..64999800a7 100644 --- a/boost/multiprecision/traits/is_byte_container.hpp +++ b/boost/multiprecision/traits/is_byte_container.hpp @@ -6,25 +6,28 @@ #ifndef BOOST_IS_BYTE_CONTAINER_HPP #define BOOST_IS_BYTE_CONTAINER_HPP +#include <iterator> #include <boost/mpl/has_xxx.hpp> #include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/remove_cv.hpp> namespace boost{ namespace multiprecision{ namespace detail{ - BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_member_value_type, value_type, false) BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_member_const_iterator, const_iterator, false) template <class C, bool b> struct is_byte_container_imp { - static const bool value = boost::is_integral<typename C::value_type>::value && (sizeof(typename C::value_type) == 1); + // Note: Don't use C::value_type as this is a rather widespread typedef, even for non-range types + typedef typename boost::remove_cv<typename std::iterator_traits<typename C::const_iterator>::value_type>::type container_value_type; + static const bool value = boost::is_integral<container_value_type>::value && (sizeof(container_value_type) == 1); }; template <class C> struct is_byte_container_imp<C, false> : public boost::false_type {}; template <class C> - struct is_byte_container : public is_byte_container_imp<C, has_member_value_type<C>::value && has_member_const_iterator<C>::value> {}; + struct is_byte_container : public is_byte_container_imp<C, has_member_const_iterator<C>::value> {}; }}} // namespaces |