]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/icl/include/boost/icl/type_traits/is_key_container_of.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / icl / include / boost / icl / type_traits / is_key_container_of.hpp
CommitLineData
7c673cae
FG
1/*-----------------------------------------------------------------------------+
2Copyright (c) 2010-2010: 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_IS_KEY_CONTAINER_OF_HPP_JOFA_100829
9#define BOOST_ICL_TYPE_TRAITS_IS_KEY_CONTAINER_OF_HPP_JOFA_100829
10
11#include <boost/mpl/has_xxx.hpp>
12#include <boost/icl/type_traits/is_combinable.hpp>
13#include <boost/icl/type_traits/is_container.hpp>
14
15namespace boost{ namespace icl
16{
17 //--------------------------------------------------------------------------
18 namespace detail
19 {
20 BOOST_MPL_HAS_XXX_TRAIT_DEF(key_object_type)
21 }
22
23 //--------------------------------------------------------------------------
24 template <class Type>
25 struct has_key_object_type
26 : mpl::bool_<detail::has_key_object_type<Type>::value>
27 {};
28
29 template <class Type, bool HasKeyContainerType, bool IsSet>
30 struct get_key_object_type;
31
32 template <class Type>
33 struct get_key_object_type<Type, false, false>
34 {
35 typedef Type no_type;
36 };
37
38 template <class Type>
39 struct get_key_object_type<Type, false, true>
40 {
41 typedef Type type;
42 };
43
44 template <class Type, bool IsSet>
45 struct get_key_object_type<Type, true, IsSet>
46 {
47 typedef typename Type::key_object_type type;
48 };
49
50 template <class Type>
51 struct key_container_type_of
52 {
53 typedef typename
54 get_key_object_type
55 < Type
56 , has_key_object_type<Type>::value
57 , mpl::or_<is_set<Type>, is_map<Type> >::value
58 >::type type;
59 };
60
61 //--------------------------------------------------------------------------
62 template<class KeyT, class ObjectT>
63 struct is_strict_key_container_of // set is_strict_key_container_of map
64 {
65 typedef is_strict_key_container_of<KeyT, ObjectT> type;
66 BOOST_STATIC_CONSTANT(bool, value =
67 (mpl::and_< is_map<ObjectT>
68 , boost::is_same<KeyT, typename key_container_type_of<ObjectT>::type> >::value)
69 );
70 };
71
72 template<class KeyT, class ObjectT>
73 struct is_key_container_of // set is_key_container_of (set or map)
74 {
75 typedef is_key_container_of<KeyT, ObjectT> type;
76 BOOST_STATIC_CONSTANT(bool, value =
77 (mpl::or_< is_strict_key_container_of<KeyT, ObjectT>
78 , mpl::and_< mpl::or_<is_set<ObjectT>, is_map<ObjectT> >
79 , boost::is_same<ObjectT, KeyT> > >::value)
80 );
81 };
82
83
84
85}} // namespace boost icl
86
87#endif
88
89