1 /*-----------------------------------------------------------------------------+
2 Copyright (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
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>
15 namespace boost{ namespace icl
17 //--------------------------------------------------------------------------
20 BOOST_MPL_HAS_XXX_TRAIT_DEF(key_object_type)
23 //--------------------------------------------------------------------------
25 struct has_key_object_type
26 : mpl::bool_<detail::has_key_object_type<Type>::value>
29 template <class Type, bool HasKeyContainerType, bool IsSet>
30 struct get_key_object_type;
33 struct get_key_object_type<Type, false, false>
39 struct get_key_object_type<Type, false, true>
44 template <class Type, bool IsSet>
45 struct get_key_object_type<Type, true, IsSet>
47 typedef typename Type::key_object_type type;
51 struct key_container_type_of
56 , has_key_object_type<Type>::value
57 , mpl::or_<is_set<Type>, is_map<Type> >::value
61 //--------------------------------------------------------------------------
62 template<class KeyT, class ObjectT>
63 struct is_strict_key_container_of // set is_strict_key_container_of map
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)
72 template<class KeyT, class ObjectT>
73 struct is_key_container_of // set is_key_container_of (set or map)
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)
85 }} // namespace boost icl