1 // Copyright (c) 2005 Daniel Wallin and Arvid Norberg
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
14 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef LUABIND_VALUE_WRAPPER_050419_HPP
24 #define LUABIND_VALUE_WRAPPER_050419_HPP
26 #include <boost/mpl/integral_c.hpp>
27 #include <boost/mpl/bool.hpp>
28 #include <boost/mpl/aux_/msvc_eti_base.hpp>
30 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
31 # define LUABIND_USE_VALUE_WRAPPER_TAG
35 #ifdef LUABIND_USE_VALUE_WRAPPER_TAG
36 # include <boost/mpl/identity.hpp>
37 # include <boost/mpl/eval_if.hpp>
38 # include <boost/mpl/has_xxx.hpp>
39 # include <boost/mpl/not.hpp>
40 # include <boost/mpl/and.hpp>
41 # include <boost/mpl/or.hpp>
42 # include <boost/type_traits/is_reference.hpp>
43 # include <boost/type_traits/is_pointer.hpp>
44 # include <boost/type_traits/is_array.hpp>
50 // Concept ``ValueWrapper``
53 #ifdef LUABIND_USE_VALUE_WRAPPER_TAG
55 struct value_wrapper_traits
;
60 BOOST_MPL_HAS_XXX_TRAIT_DEF(value_wrapper_tag
);
62 struct unspecialized_value_wrapper_traits
64 typedef boost::mpl::false_ is_specialized
;
68 struct value_wrapper_traits_aux
70 typedef value_wrapper_traits
<typename
T::value_wrapper_tag
> type
;
77 struct value_wrapper_traits
78 #ifdef LUABIND_USE_VALUE_WRAPPER_TAG
79 : boost::mpl::eval_if
<
83 boost::is_reference
<T
>
84 , boost::is_pointer
<T
>
88 , detail::has_value_wrapper_tag
<T
>
90 , detail::value_wrapper_traits_aux
<T
>
91 , boost::mpl::identity
<detail::unspecialized_value_wrapper_traits
>
96 typedef boost::mpl::false_ is_specialized
;
101 struct is_value_wrapper
102 : boost::mpl::aux::msvc_eti_base
<
103 typename value_wrapper_traits
<T
>::is_specialized
107 } // namespace luabind
109 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
111 # include <boost/type_traits/remove_const.hpp>
112 # include <boost/type_traits/remove_reference.hpp>
117 struct is_value_wrapper_arg
119 typename
boost::remove_const
<
120 typename
boost::remove_reference
<T
>::type
125 } // namespace luabind
129 # include <luabind/detail/yes_no.hpp>
130 # include <boost/type_traits/add_reference.hpp>
137 typename is_value_wrapper
<T
>::type
is_value_wrapper_arg_check(T
const*);
139 yes_t
to_yesno(boost::mpl::true_
);
140 no_t
to_yesno(boost::mpl::false_
);
143 struct is_value_wrapper_arg_aux
145 static typename
boost::add_reference
<T
>::type x
;
147 BOOST_STATIC_CONSTANT(bool, value
=
148 sizeof(to_yesno(is_value_wrapper_arg_check(&x
)))
152 typedef boost::mpl::bool_
<value
> type
;
155 } // namespace detail
158 struct is_value_wrapper_arg
159 : detail::is_value_wrapper_arg_aux
<T
>::type
163 } // namespace luabind
167 #endif // LUABIND_VALUE_WRAPPER_050419_HPP