1// Boost.Range library
2//
3// Copyright Neil Groves 2014.
4//
5// Use, modification and distribution are subject to the Boost Software License,
6// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt).
8//
9// For more information, see http://www.boost.org/libs/range/
10//
11#ifndef BOOST_RANGE_DETAIL_HAS_MEMBER_SIZE_HPP
12#define BOOST_RANGE_DETAIL_HAS_MEMBER_SIZE_HPP
13
14#include <boost/type_traits/is_class.hpp>
15#include <boost/type_traits/is_member_function_pointer.hpp>
16#include <boost/mpl/and.hpp>
17#include <boost/mpl/bool.hpp>
18#include <boost/cstdint.hpp>
19
20namespace boost
21{
22 namespace range_detail
23 {
24
25template<class T>
26class has_member_size_impl
27{
28private:
29 template<class U, U>
30 class check
31 {
32 };
33
34 template<class C>
35 static boost::uint8_t f(check<std::size_t(C::*)(void) const, &C::size>*);
36
37 template<class C>
38 static boost::uint16_t f(...);
39
40public:
41 static const bool value =
42 (sizeof(f<T>(0)) == sizeof(boost::uint8_t));
43
44 typedef typename mpl::if_c<
45 (sizeof(f<T>(0)) == sizeof(boost::uint8_t)),
46 mpl::true_,
47 mpl::false_
48 >::type type;
49};
50
51template<class T>
52struct has_member_size
53{
54 typedef typename mpl::and_<
55 typename is_class<T>::type,
56 typename has_member_size_impl<const T>::type
57 >::type type;
58
59 static const bool value =
60 is_class<T>::value && has_member_size_impl<const T>::value;
61};
62
63 } // namespace range_detail
64}// namespace boost
65
66#endif // include guard
67

source code of boost/boost/range/detail/has_member_size.hpp