|
1 // Copyright (C) 2004 Arkadiy Vertleyb |
|
2 // Distributed under the Boost Software License, Version 1.0. (See accompanying |
|
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
|
4 |
|
5 #ifndef BOOST_TYPEOF_MODIFIERS_HPP_INCLUDED |
|
6 #define BOOST_TYPEOF_MODIFIERS_HPP_INCLUDED |
|
7 |
|
8 #include <boost/typeof/encode_decode.hpp> |
|
9 #include <boost/preprocessor/facilities/identity.hpp> |
|
10 |
|
11 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() |
|
12 |
|
13 // modifiers |
|
14 |
|
15 #define BOOST_TYPEOF_modifier_support(ID, Fun)\ |
|
16 template<class V, class T> struct encode_type_impl<V, Fun(T)>\ |
|
17 {\ |
|
18 typedef\ |
|
19 typename boost::type_of::encode_type<\ |
|
20 typename boost::type_of::push_back<\ |
|
21 V\ |
|
22 , boost::mpl::size_t<ID> >::type\ |
|
23 , T>::type\ |
|
24 type;\ |
|
25 };\ |
|
26 template<class Iter> struct decode_type_impl<boost::mpl::size_t<ID>, Iter>\ |
|
27 {\ |
|
28 typedef boost::type_of::decode_type<Iter> d1;\ |
|
29 typedef Fun(typename d1::type) type;\ |
|
30 typedef typename d1::iter iter;\ |
|
31 } |
|
32 |
|
33 #define BOOST_TYPEOF_const_fun(T) const T |
|
34 #define BOOST_TYPEOF_volatile_fun(T) volatile T |
|
35 #define BOOST_TYPEOF_volatile_const_fun(T) volatile const T |
|
36 #define BOOST_TYPEOF_pointer_fun(T) T* |
|
37 #define BOOST_TYPEOF_reference_fun(T) T& |
|
38 |
|
39 BOOST_TYPEOF_BEGIN_ENCODE_NS |
|
40 |
|
41 BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_const_fun); |
|
42 BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_volatile_fun); |
|
43 BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_volatile_const_fun); |
|
44 BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_pointer_fun); |
|
45 BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_reference_fun); |
|
46 |
|
47 BOOST_TYPEOF_END_ENCODE_NS |
|
48 |
|
49 #undef BOOST_TYPEOF_modifier_support |
|
50 #undef BOOST_TYPEOF_const_fun |
|
51 #undef BOOST_TYPEOF_volatile_fun |
|
52 #undef BOOST_TYPEOF_volatile_const_fun |
|
53 #undef BOOST_TYPEOF_pointer_fun |
|
54 #undef BOOST_TYPEOF_reference_fun |
|
55 |
|
56 // arrays |
|
57 |
|
58 #define BOOST_TYPEOF_array_support(ID, Qualifier)\ |
|
59 template<class V, class T, int N>\ |
|
60 struct encode_type_impl<V, Qualifier() T[N]>\ |
|
61 {\ |
|
62 typedef\ |
|
63 typename boost::type_of::encode_type<\ |
|
64 typename boost::type_of::push_back<\ |
|
65 typename boost::type_of::push_back<\ |
|
66 V\ |
|
67 , boost::mpl::size_t<ID> >::type\ |
|
68 , boost::mpl::size_t<N> >::type\ |
|
69 , T>::type\ |
|
70 type;\ |
|
71 };\ |
|
72 template<class Iter>\ |
|
73 struct decode_type_impl<boost::mpl::size_t<ID>, Iter>\ |
|
74 {\ |
|
75 enum{n = Iter::type::value};\ |
|
76 typedef boost::type_of::decode_type<typename Iter::next> d;\ |
|
77 typedef typename d::type Qualifier() type[n];\ |
|
78 typedef typename d::iter iter;\ |
|
79 } |
|
80 |
|
81 BOOST_TYPEOF_BEGIN_ENCODE_NS |
|
82 |
|
83 BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_EMPTY); |
|
84 BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(const)); |
|
85 BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(volatile)); |
|
86 BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(volatile const)); |
|
87 |
|
88 BOOST_TYPEOF_END_ENCODE_NS |
|
89 |
|
90 #undef BOOST_TYPEOF_array_support |
|
91 |
|
92 #endif//BOOST_TYPEOF_MODIFIERS_HPP_INCLUDED |