is_byte_container.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright 2015 John Maddock. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_IS_BYTE_CONTAINER_HPP
  6. #define BOOST_IS_BYTE_CONTAINER_HPP
  7. #include <iterator>
  8. #include <boost/mpl/has_xxx.hpp>
  9. #include <boost/type_traits/is_integral.hpp>
  10. #include <boost/type_traits/remove_cv.hpp>
  11. namespace boost { namespace multiprecision { namespace detail {
  12. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_member_const_iterator, const_iterator, false)
  13. template <class C, bool b>
  14. struct is_byte_container_imp
  15. {
  16. // Note: Don't use C::value_type as this is a rather widespread typedef, even for non-range types
  17. typedef typename boost::remove_cv<typename std::iterator_traits<typename C::const_iterator>::value_type>::type container_value_type;
  18. static const bool value = boost::is_integral<container_value_type>::value && (sizeof(container_value_type) == 1);
  19. };
  20. template <class C>
  21. struct is_byte_container_imp<C, false> : public boost::false_type
  22. {};
  23. template <class C>
  24. struct is_byte_container : public is_byte_container_imp<C, has_member_const_iterator<C>::value>
  25. {};
  26. }}} // namespace boost::multiprecision::detail
  27. #endif // BOOST_IS_BYTE_CONTAINER_HPP