]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/icl/type_traits/element_type_of.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / icl / type_traits / element_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_ELEMENT_TYPE_OF_HPP_JOFA_100902
9 #define BOOST_ICL_TYPE_TRAITS_ELEMENT_TYPE_OF_HPP_JOFA_100902
10
11 #include <boost/mpl/has_xxx.hpp>
12 #include <boost/mpl/bool.hpp>
13 #include <boost/icl/type_traits/no_type.hpp>
14
15 namespace boost{ namespace icl
16 {
17 namespace detail
18 {
19 BOOST_MPL_HAS_XXX_TRAIT_DEF(element_type)
20 BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
21 BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type)
22 }
23
24 //--------------------------------------------------------------------------
25 template <class Type>
26 struct has_element_type
27 : mpl::bool_<detail::has_element_type<Type>::value>
28 {};
29
30 template <class Type, bool has_element_type>
31 struct get_element_type;
32
33 template <class Type>
34 struct get_element_type<Type, false>
35 {
36 typedef no_type type;
37 };
38
39 template <class Type>
40 struct get_element_type<Type, true>
41 {
42 typedef typename Type::element_type type;
43 };
44
45 template <class Type>
46 struct element_type_of
47 {
48 typedef typename
49 get_element_type<Type, has_element_type<Type>::value>::type type;
50 };
51
52 //--------------------------------------------------------------------------
53 template <class Type>
54 struct has_value_type
55 : mpl::bool_<detail::has_value_type<Type>::value>
56 {};
57
58 template <class Type, bool has_value_type>
59 struct get_value_type;
60
61 template <class Type>
62 struct get_value_type<Type, false>
63 {
64 typedef no_type type;
65 };
66
67 template <class Type>
68 struct get_value_type<Type, true>
69 {
70 typedef typename Type::value_type type;
71 };
72
73 template <class Type>
74 struct value_type_of
75 {
76 typedef typename
77 get_value_type<Type, has_value_type<Type>::value>::type type;
78 };
79
80 //--------------------------------------------------------------------------
81 template <class Type>
82 struct has_key_type
83 : mpl::bool_<detail::has_key_type<Type>::value>
84 {};
85
86 template <class Type, bool has_key_type>
87 struct get_key_type;
88
89 template <class Type>
90 struct get_key_type<Type, false>
91 {
92 typedef no_type type;
93 };
94
95 template <class Type>
96 struct get_key_type<Type, true>
97 {
98 typedef typename Type::key_type type;
99 };
100
101 template <class Type>
102 struct key_type_of
103 {
104 typedef typename
105 get_key_type<Type, has_key_type<Type>::value>::type type;
106 };
107
108 }} // namespace boost icl
109
110 #endif
111
112