Ardour  9.0-pre0-582-g084a23a80d
TypeTraits.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 /*
3  https://github.com/vinniefalco/LuaBridge
4 
5  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
6 
7  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
8 
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:
15 
16  The above copyright notice and this permission notice shall be included in all
17  copies or substantial portions of the Software.
18 
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
25  SOFTWARE.
26 */
27 //==============================================================================
28 
29 #ifndef LUABRIDGE_TYPEINFO_HEADER
30 #define LUABRIDGE_TYPEINFO_HEADER
31 
32 //------------------------------------------------------------------------------
56 template <class T>
58 {
59  typedef bool isNotContainer;
60 };
61 
62 //------------------------------------------------------------------------------
68 struct TypeTraits
69 {
75  template <typename T>
77  {
78  private:
79  typedef char yes[1]; // sizeof (yes) == 1
80  typedef char no [2]; // sizeof (no) == 2
81 
82  template <typename C>
83  static no& test (typename C::isNotContainer*);
84 
85  template <typename>
86  static yes& test (...);
87 
88  public:
89  static const bool value = sizeof (test <ContainerTraits <T> >(0)) == sizeof (yes);
90  };
91 
92 
96  template <class T>
97  struct isConst
98  {
99  static bool const value = false;
100  };
101 
102  template <class T>
103  struct isConst <T const>
104  {
105  static bool const value = true;
106  };
112  template <class T>
113  struct removeConst
114  {
115  typedef T Type;
116  };
117 
118  template <class T>
119  struct removeConst <T const>
120  {
121  typedef T Type;
122  };
124 };
125 
126 #endif
static const bool value
Definition: TypeTraits.h:89
static yes & test(...)
static no & test(typename C::isNotContainer *)
bool isNotContainer
Definition: TypeTraits.h:59
static bool const value
Definition: TypeTraits.h:99