]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
92f5a8d4 | 9 | #include <iterator> |
1e59de90 | 10 | #include <type_traits> |
7c673cae | 11 | |
92f5a8d4 | 12 | namespace boost { namespace multiprecision { namespace detail { |
7c673cae | 13 | |
1e59de90 TL |
14 | template <class T> |
15 | struct has_member_const_iterator | |
16 | { | |
17 | template <class U> | |
18 | static double check(U*, typename U::const_iterator* = nullptr); | |
19 | static char check(...); | |
20 | static T* get(); | |
21 | static constexpr bool value = sizeof(check(get())) == sizeof(double); | |
22 | }; | |
23 | ||
24 | ||
25 | template <class C, class Iterator> | |
26 | struct is_byte_container_imp_2 | |
27 | { | |
28 | using container_value_type = typename std::remove_cv<typename std::iterator_traits<typename C::const_iterator>::value_type>::type; | |
29 | static constexpr const bool value = boost::multiprecision::detail::is_integral<container_value_type>::value && (sizeof(container_value_type) == 1); | |
30 | }; | |
31 | ||
32 | template <class C> | |
33 | struct is_byte_container_imp_2<C, void> : public std::false_type | |
34 | {}; | |
7c673cae | 35 | |
92f5a8d4 | 36 | template <class C, bool b> |
1e59de90 | 37 | struct is_byte_container_imp : public is_byte_container_imp_2<C, typename C::const_iterator> |
92f5a8d4 | 38 | { |
92f5a8d4 | 39 | }; |
7c673cae | 40 | |
92f5a8d4 | 41 | template <class C> |
1e59de90 | 42 | struct is_byte_container_imp<C, false> : public std::false_type |
92f5a8d4 | 43 | {}; |
7c673cae | 44 | |
92f5a8d4 TL |
45 | template <class C> |
46 | struct is_byte_container : public is_byte_container_imp<C, has_member_const_iterator<C>::value> | |
47 | {}; | |
7c673cae | 48 | |
92f5a8d4 | 49 | }}} // namespace boost::multiprecision::detail |
7c673cae FG |
50 | |
51 | #endif // BOOST_IS_BYTE_CONTAINER_HPP |