NiHu  2.0
defines_type.hpp
Go to the documentation of this file.
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
24 #ifndef DEFINES_TYPE_HPP_INCLUDED
25 #define DEFINES_TYPE_HPP_INCLUDED
26 
27 #include <type_traits>
28 
29 namespace internal
30 {
32  template <class C>
33  struct voidize { typedef void type; };
34 }
35 
36 #define DEFINES_TYPE(TYPE) \
37 template <class C, class = void> \
38 struct defines_##TYPE : std::false_type {}; \
39 template <class C> \
40  \
41 struct defines_##TYPE < \
42  C, \
43  typename internal::voidize<typename C::TYPE>::type \
44 > : std::true_type { };
45 
46 #endif // DEFINES_TYPE_HPP_INCLUDED