Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / multiprecision / traits / is_byte_container.hpp
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
6 #ifndef BOOST_IS_BYTE_CONTAINER_HPP
7 #define BOOST_IS_BYTE_CONTAINER_HPP
8
9 #include <iterator>
10 #include <boost/mpl/has_xxx.hpp>
11 #include <boost/type_traits/is_integral.hpp>
12 #include <boost/type_traits/remove_cv.hpp>
13
14 namespace boost { namespace multiprecision { namespace detail {
15
16 BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_member_const_iterator, const_iterator, false)
17
18 template <class C, bool b>
19 struct is_byte_container_imp
20 {
21    // Note: Don't use C::value_type as this is a rather widespread typedef, even for non-range types
22    typedef typename boost::remove_cv<typename std::iterator_traits<typename C::const_iterator>::value_type>::type container_value_type;
23    static const bool                                                                                              value = boost::is_integral<container_value_type>::value && (sizeof(container_value_type) == 1);
24 };
25
26 template <class C>
27 struct is_byte_container_imp<C, false> : public boost::false_type
28 {};
29
30 template <class C>
31 struct is_byte_container : public is_byte_container_imp<C, has_member_const_iterator<C>::value>
32 {};
33
34 }}} // namespace boost::multiprecision::detail
35
36 #endif // BOOST_IS_BYTE_CONTAINER_HPP