libpnicore
sfinae_macros.hpp
1 //
2 // (c) Copyright 2013 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpnicore.
5 //
6 // libpnicore 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 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpnicore 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 libpnicore. If not, see <http://www.gnu.org/licenses/>.
18 //
19 // ============================================================================
20 //
21 // Created on: Nov 07, 2013
22 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
23 //
24 
25 #pragma once
26 
27 #include <type_traits>
28 #include "../types/traits.hpp"
29 #include "../types/complex_utils.hpp"
30 
31 namespace pni{
32 namespace core{
33 
42  template<typename T> using invoke = typename T::type;
43 
44  //------------------------------------------------------------------------
56  template<
57  typename T1,
58  typename T2
59  >
60  struct or_t
61  {
63  static const bool value = T1::value || T2::value;
64  };
65 
66  //------------------------------------------------------------------------
78  template<
79  typename T1,
80  typename T2
81  >
82  struct and_t
83  {
85  static const bool value = T1::value && T2::value;
86  };
87 
88  //------------------------------------------------------------------------
97  template<typename T> struct not_t
98  {
100  static const bool value = !T::value;
101  };
102 
103  //------------------------------------------------------------------------
108  template<typename C> using enable_if = invoke<std::enable_if<C::value>>;
109 
110  //------------------------------------------------------------------------
115  template<typename T> using is_pod = std::is_pod<T>;
116 
117  //------------------------------------------------------------------------
122  template<typename T> using is_ptr = std::is_pointer<T>;
123 
124  //------------------------------------------------------------------------
129  template<typename T> using is_cmplx = is_complex_type<T>;
130 
131 //end of namespace
132 }
133 }
134 
135 
and type
Definition: sfinae_macros.hpp:82
std::is_pointer< T > is_ptr
shortcut for std::is_pointer
Definition: sfinae_macros.hpp:122
check complex type
Definition: traits.hpp:74
logical not
Definition: sfinae_macros.hpp:97
typename T::type invoke
alias to invoke a metafunction
Definition: sfinae_macros.hpp:42
Definition: add_op.hpp:29
invoke< std::enable_if< C::value >> enable_if
shortcut for std::enable_if
Definition: sfinae_macros.hpp:108
std::is_pod< T > is_pod
shortcut for std::is_pod
Definition: sfinae_macros.hpp:115
or type
Definition: sfinae_macros.hpp:60
type erasure for POD data
Definition: value.hpp:46