]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/icl/type_traits/size_type_of.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / icl / type_traits / size_type_of.hpp
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2008-2009: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 #ifndef BOOST_ICL_TYPE_TRAITS_SIZE_TYPE_OF_HPP_JOFA_080911
9 #define BOOST_ICL_TYPE_TRAITS_SIZE_TYPE_OF_HPP_JOFA_080911
10
11 #include <boost/mpl/has_xxx.hpp>
12 #include <boost/icl/type_traits/difference_type_of.hpp>
13
14 namespace boost{ namespace icl
15 {
16
17 namespace detail
18 {
19 BOOST_MPL_HAS_XXX_TRAIT_DEF(size_type)
20 }
21
22 //--------------------------------------------------------------------------
23 template <class Type>
24 struct has_size_type
25 : mpl::bool_<detail::has_size_type<Type>::value>
26 {};
27
28 //--------------------------------------------------------------------------
29 template <class Type, bool has_size, bool has_diff, bool has_rep>
30 struct get_size_type;
31
32 template <class Type>
33 struct get_size_type<Type, false, false, false>
34 {
35 typedef std::size_t type;
36 };
37
38 template <class Type, bool has_diff, bool has_rep>
39 struct get_size_type<Type, true, has_diff, has_rep>
40 {
41 typedef typename Type::size_type type;
42 };
43
44 template <class Type, bool has_rep>
45 struct get_size_type<Type, false, true, has_rep>
46 {
47 typedef typename Type::difference_type type;
48 };
49
50 template <class Type>
51 struct get_size_type<Type, false, false, true>
52 {
53 typedef Type type;
54 };
55
56 //--------------------------------------------------------------------------
57 template<class Type>
58 struct size_type_of
59 {
60 typedef typename
61 get_size_type< Type
62 , has_size_type<Type>::value
63 , has_difference_type<Type>::value
64 , has_rep_type<Type>::value
65 >::type type;
66 };
67
68 }} // namespace boost icl
69
70 #endif
71
72