]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.TypeErasure library |
2 | // | |
3 | // Copyright 2011 Steven Watanabe | |
4 | // | |
5 | // Distributed under the Boost Software License Version 1.0. (See | |
6 | // accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | // | |
9 | // $Id$ | |
10 | ||
11 | #ifndef BOOST_TYPE_ERASURE_DETAIL_ACCESS_HPP_INCLUDED | |
12 | #define BOOST_TYPE_ERASURE_DETAIL_ACCESS_HPP_INCLUDED | |
13 | ||
14 | #include <boost/type_erasure/detail/storage.hpp> | |
15 | #include <boost/type_erasure/detail/any_base.hpp> | |
16 | ||
17 | namespace boost { | |
18 | namespace type_erasure { | |
19 | ||
20 | template<class Concept, class T> | |
21 | class any; | |
22 | ||
23 | template<class Concept, class T> | |
24 | class param; | |
25 | ||
26 | namespace detail { | |
27 | ||
28 | struct access | |
29 | { | |
30 | template<class Derived> | |
31 | static const typename Derived::table_type& | |
32 | table(const ::boost::type_erasure::any_base<Derived>& arg) | |
33 | { | |
34 | return static_cast<const Derived&>(arg).table; | |
35 | } | |
36 | template<class Concept, class T> | |
37 | static const typename any<Concept, T>::table_type& | |
38 | table(const ::boost::type_erasure::param<Concept, T>& arg) | |
39 | { | |
40 | return arg._impl.table; | |
41 | } | |
42 | template<class Derived> | |
43 | static ::boost::type_erasure::detail::storage& | |
44 | data(::boost::type_erasure::any_base<Derived>& arg) | |
45 | { | |
46 | return static_cast<Derived&>(arg).data; | |
47 | } | |
48 | template<class Concept, class T> | |
49 | static const ::boost::type_erasure::detail::storage& | |
50 | data(::boost::type_erasure::any_base< ::boost::type_erasure::any<Concept, const T&> >& arg) | |
51 | { | |
52 | return static_cast< ::boost::type_erasure::any<Concept, const T&>&>(arg).data; | |
53 | } | |
54 | template<class Derived> | |
55 | static const ::boost::type_erasure::detail::storage& | |
56 | data(const ::boost::type_erasure::any_base<Derived>& arg) | |
57 | { | |
58 | return static_cast<const Derived&>(arg).data; | |
59 | } | |
60 | template<class Concept, class T> | |
61 | static ::boost::type_erasure::detail::storage& | |
62 | data(const ::boost::type_erasure::any_base< ::boost::type_erasure::any<Concept, T&> >& arg) | |
63 | { | |
64 | return const_cast< ::boost::type_erasure::detail::storage&>(static_cast< const ::boost::type_erasure::any<Concept, T&>&>(arg).data); | |
65 | } | |
66 | template<class Concept, class T> | |
67 | static const ::boost::type_erasure::detail::storage& | |
68 | data(const ::boost::type_erasure::any_base< ::boost::type_erasure::any<Concept, const T&> >& arg) | |
69 | { | |
70 | return static_cast<const ::boost::type_erasure::any<Concept, const T&>&>(arg).data; | |
71 | } | |
72 | template<class Concept, class T> | |
73 | static ::boost::type_erasure::detail::storage& | |
74 | data(::boost::type_erasure::param<Concept, T>& arg) | |
75 | { | |
76 | return arg._impl.data; | |
77 | } | |
78 | template<class Concept, class T> | |
79 | static const ::boost::type_erasure::detail::storage& | |
80 | data(::boost::type_erasure::param<Concept, const T&>& arg) | |
81 | { | |
82 | return arg._impl.data; | |
83 | } | |
84 | template<class Concept, class T> | |
85 | static const ::boost::type_erasure::detail::storage& | |
86 | data(const ::boost::type_erasure::param<Concept, T>& arg) | |
87 | { | |
88 | return arg._impl.data; | |
89 | } | |
90 | ||
91 | #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES | |
92 | ||
93 | template<class Derived> | |
94 | static ::boost::type_erasure::detail::storage&& | |
95 | data(::boost::type_erasure::any_base<Derived>&& arg) | |
96 | { | |
97 | return std::move(static_cast<Derived&>(arg).data); | |
98 | } | |
99 | template<class Concept, class T> | |
100 | static ::boost::type_erasure::detail::storage&& | |
101 | data(::boost::type_erasure::any_base< ::boost::type_erasure::any<Concept, T&&> >& arg) | |
102 | { | |
103 | return std::move(static_cast< ::boost::type_erasure::any<Concept, T&&>&>(arg).data); | |
104 | } | |
105 | template<class Concept, class T> | |
106 | static ::boost::type_erasure::detail::storage&& | |
107 | data(const ::boost::type_erasure::any_base< ::boost::type_erasure::any<Concept, T&&> >& arg) | |
108 | { | |
109 | return std::move(const_cast< ::boost::type_erasure::detail::storage&>(static_cast< const ::boost::type_erasure::any<Concept, T&&>&>(arg).data)); | |
110 | } | |
111 | ||
112 | template<class Concept, class T> | |
113 | static ::boost::type_erasure::detail::storage&& | |
114 | data(::boost::type_erasure::param<Concept, T>&& arg) | |
115 | { | |
116 | return std::move(arg._impl.data); | |
117 | } | |
118 | template<class Concept, class T> | |
119 | static ::boost::type_erasure::detail::storage&& | |
120 | data(::boost::type_erasure::param<Concept, T&&>& arg) | |
121 | { | |
122 | return std::move(arg._impl.data); | |
123 | } | |
124 | template<class Concept, class T> | |
125 | static ::boost::type_erasure::detail::storage&& | |
126 | data(const ::boost::type_erasure::param<Concept, T&&>& arg) | |
127 | { | |
128 | return std::move(const_cast< ::boost::type_erasure::detail::storage&>(arg._impl.data)); | |
129 | } | |
130 | ||
131 | #endif | |
132 | ||
133 | }; | |
134 | ||
135 | } | |
136 | } | |
137 | } | |
138 | ||
139 | #endif |