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
11 #include <boost/mpl/has_xxx.hpp>
12 #include <boost/mpl/bool.hpp>
13 #include <boost/icl/type_traits/no_type.hpp>
15 namespace boost{ namespace icl
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)
24 //--------------------------------------------------------------------------
26 struct has_element_type
27 : mpl::bool_<detail::has_element_type<Type>::value>
30 template <class Type, bool has_element_type>
31 struct get_element_type;
34 struct get_element_type<Type, false>
40 struct get_element_type<Type, true>
42 typedef typename Type::element_type type;
46 struct element_type_of
49 get_element_type<Type, has_element_type<Type>::value>::type type;
52 //--------------------------------------------------------------------------
55 : mpl::bool_<detail::has_value_type<Type>::value>
58 template <class Type, bool has_value_type>
59 struct get_value_type;
62 struct get_value_type<Type, false>
68 struct get_value_type<Type, true>
70 typedef typename Type::value_type type;
77 get_value_type<Type, has_value_type<Type>::value>::type type;
80 //--------------------------------------------------------------------------
83 : mpl::bool_<detail::has_key_type<Type>::value>
86 template <class Type, bool has_key_type>
90 struct get_key_type<Type, false>
96 struct get_key_type<Type, true>
98 typedef typename Type::key_type type;
101 template <class Type>
105 get_key_type<Type, has_key_type<Type>::value>::type type;
108 }} // namespace boost icl