OSDN Git Service

build moflib1.0 on cmake-base system
[moflib/moflib.git] / moflib-1.0 / extlib / luabind-0.8 / luabind / detail / has_get_pointer.hpp
1 // Copyright (c) 2005 Daniel Wallin
2
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:
9
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
12
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.
22
23 #ifndef LUABIND_HAS_GET_POINTER_051022_HPP
24 # define LUABIND_HAS_GET_POINTER_051022_HPP
25
26 # include <boost/type_traits/add_reference.hpp>
27
28 # ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
29 #  include <memory>
30 # endif
31
32 namespace luabind { namespace detail { 
33
34 namespace has_get_pointer_
35 {
36
37   struct any 
38   { 
39       template<class T> any(T const&);
40   };
41
42   struct no_overload_tag 
43   {};
44
45   typedef char (&yes)[1];
46   typedef char (&no)[2];
47
48   no_overload_tag operator,(no_overload_tag, int);
49
50 //
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.
54 //
55 # ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
56
57   template<class T>
58   T* get_pointer(T const volatile*);
59
60   template<class T>
61   T* get_pointer(std::auto_ptr<T> const&);
62
63 # endif
64
65 //
66 // On compilers that doesn't support ADL, the overload below has to
67 // live in luabind::.
68 //
69 # ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
70 }} // namespace detail::has_get_pointer_
71 # endif
72
73 detail::has_get_pointer_::no_overload_tag 
74   get_pointer(detail::has_get_pointer_::any);
75
76 # ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
77 namespace detail { namespace has_get_pointer_ 
78 {
79 # endif
80
81   template<class T>
82   yes check(T const&);
83   no check(no_overload_tag);
84
85   template<class T>
86   struct impl
87   {
88       static typename boost::add_reference<T>::type x;
89
90       BOOST_STATIC_CONSTANT(bool,
91           value = sizeof(has_get_pointer_::check( (get_pointer(x),0) )) == 1
92       );
93
94       typedef boost::mpl::bool_<value> type;
95   };
96
97 } // namespace has_get_pointer_
98
99 template<class T>
100 struct has_get_pointer
101   : has_get_pointer_::impl<T>::type
102 {};
103
104 }} // namespace luabind::detail
105
106 #endif // LUABIND_HAS_GET_POINTER_051022_HPP
107