Teach adopt() to hold the adopted pointer in custom pointer type.
[luabind.git] / test / test_value_wrapper.cpp
blob2b8837ac606f687a7c017818258ee02f92e3f309
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 #include <luabind/value_wrapper.hpp>
24 #include <luabind/object.hpp>
25 #include <boost/mpl/assert.hpp>
27 struct X_tag;
29 struct X
31 typedef X_tag value_wrapper_tag;
34 namespace luabind
36 #ifdef LUABIND_USE_VALUE_WRAPPER_TAG
37 template<>
38 struct value_wrapper_traits<X_tag>
40 typedef boost::mpl::true_ is_specialized;
42 #else
43 // used on compilers supporting partial template specialization
44 template<>
45 struct value_wrapper_traits<X>
47 typedef boost::mpl::true_ is_specialized;
49 #endif
51 } // namespace luabind
53 BOOST_MPL_ASSERT(( luabind::is_value_wrapper<X> ));
54 BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper<X&> ));
55 BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper<X const&> ));
57 BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X> ));
58 BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X const> ));
59 BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X&> ));
60 BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X const&> ));
61 BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper_arg<int> ));
62 BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper_arg<int[4]> ));
64 BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X const&> ));
65 BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<luabind::object&> ));
66 BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<luabind::object const&> ));
68 int main()