1 // Copyright (c) 2005 Daniel Wallin
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_HAS_GET_POINTER_051022_HPP
24 # define LUABIND_HAS_GET_POINTER_051022_HPP
26 # include <boost/type_traits/add_reference.hpp>
28 # ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
32 namespace luabind
{ namespace detail
{
34 namespace has_get_pointer_
39 template<class T
> any(T
const&);
42 struct no_overload_tag
45 typedef char (&yes
)[1];
46 typedef char (&no
)[2];
48 no_overload_tag
operator,(no_overload_tag
, int);
51 // On compilers with ADL, we need these generic overloads in this
52 // namespace as well as in luabind::. Otherwise get_pointer(any)
53 // will be found before them.
55 # ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
58 T
* get_pointer(T
const volatile*);
61 T
* get_pointer(std::auto_ptr
<T
> const&);
66 // On compilers that doesn't support ADL, the overload below has to
69 # ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
70 }} // namespace detail::has_get_pointer_
73 detail::has_get_pointer_::no_overload_tag
74 get_pointer(detail::has_get_pointer_::any
);
76 # ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
77 namespace detail
{ namespace has_get_pointer_
83 no
check(no_overload_tag
);
88 static typename
boost::add_reference
<T
>::type x
;
90 BOOST_STATIC_CONSTANT(bool,
91 value
= sizeof(has_get_pointer_::check( (get_pointer(x
),0) )) == 1
94 typedef boost::mpl::bool_
<value
> type
;
97 } // namespace has_get_pointer_
100 struct has_get_pointer
101 : has_get_pointer_::impl
<T
>::type
104 }} // namespace luabind::detail
106 #endif // LUABIND_HAS_GET_POINTER_051022_HPP