1 //------------------------------------------------------------------------------
3 https://github.com/vinniefalco/LuaBridge
5 Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
7 License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in all
17 copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 //==============================================================================
29 #ifndef LUABRIDGE_TYPEINFO_HEADER
30 #define LUABRIDGE_TYPEINFO_HEADER
32 //------------------------------------------------------------------------------
36 Unspecialized ContainerTraits has the isNotContainer typedef for SFINAE.
37 All user defined containers must supply an appropriate specialization for
38 ContinerTraits (without the typedef isNotContainer). The containers that
39 come with LuaBridge also come with the appropriate ContainerTraits
40 specialization. See the corresponding declaration for details.
42 A specialization of ContainerTraits for some generic type ContainerType
46 struct ContainerTraits <ContainerType <T> >
48 typedef typename T Type;
50 static T* get (ContainerType <T> const& c)
52 return c.get (); // Implementation-dependent on ContainerType
57 struct ContainerTraits
59 typedef bool isNotContainer;
62 //------------------------------------------------------------------------------
66 Specializations return information about a type.
70 /** Determine if type T is a container.
72 To be considered a container, there must be a specialization of
73 ContainerTraits with the required fields.
79 typedef char yes[1]; // sizeof (yes) == 1
80 typedef char no [2]; // sizeof (no) == 2
83 static no& test (typename C::isNotContainer*);
86 static yes& test (...);
89 static const bool value = sizeof (test <ContainerTraits <T> >(0)) == sizeof (yes);
92 /** Determine if T is an enum */
97 //static const bool value = std::is_enum<T>::value; // C++11
98 static const bool value = boost::is_enum<T>::value;
102 /** Determine if T is const qualified.
108 static bool const value = false;
112 struct isConst <T const>
114 static bool const value = true;
118 /** Remove the const qualifier from T.
128 struct removeConst <T const>