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_REP_TYPE_OF_HPP_JOFA_110329
9 #define BOOST_ICL_TYPE_TRAITS_REP_TYPE_OF_HPP_JOFA_110329
10 
11 #include <boost/config.hpp> // For macro BOOST_STATIC_CONSTANT
12 #include <boost/mpl/has_xxx.hpp>
13 #include <boost/mpl/or.hpp>
14 #include <boost/mpl/and.hpp>
15 #include <boost/mpl/not.hpp>
16 #include <boost/icl/type_traits/no_type.hpp>
17 
18 namespace boost{ namespace icl
19 {
20     namespace detail
21     {
22         BOOST_MPL_HAS_XXX_TRAIT_DEF(rep)
23     }
24 
25     //--------------------------------------------------------------------------
26     template <class Type>
27     struct has_rep_type
28       : mpl::bool_<detail::has_rep<Type>::value>
29     {};
30 
31     template <class Rep, class Type>
32     struct represents // Rep represents Type;  Type is_wrapper_of Rep
33       : mpl::bool_<detail::has_rep<Type>::value>
34     {
35         typedef represents type;
36         BOOST_STATIC_CONSTANT(bool,
37             value = (mpl::and_< has_rep_type<Type>
38                               , is_same<typename Type::rep, Rep> >::value)
39             );
40     };
41 
42     //--------------------------------------------------------------------------
43     template <class Type, bool has_rep>
44     struct get_rep_type;
45 
46     template <class Type>
47     struct get_rep_type<Type, false>
48     {
49         typedef no_type type;
50     };
51 
52     template <class Type>
53     struct get_rep_type<Type, true>
54     {
55         typedef typename Type::rep type;
56     };
57 
58     //--------------------------------------------------------------------------
59     template<class Type>
60     struct rep_type_of
61     {
62         typedef typename
63             get_rep_type<Type, has_rep_type<Type>::value>::type type;
64     };
65 
66 }} // namespace boost icl
67 
68 #endif
69 
70 
71