cuda-kat
CUDA kernel author's tools
common.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 #ifndef CUDA_KAT_COMMON_HPP_
8 #define CUDA_KAT_COMMON_HPP_
9 
10 #include <cstddef> // for std::size_t
11 #include <type_traits>
12 
13 #include <kat/detail/execution_space_specifiers.hpp>
14 #include <kat/detail/constexpr_by_cpp_version.hpp>
15 
16 namespace kat {
17 
26 using size_t = std::size_t;
27 
28 #if __cplusplus < 201703L
29 
30 // Some C++17 type traits definable in C++11
31 
32 template<typename ... > struct conjunction : std::true_type {};
33 template<typename B > struct conjunction<B> : B {};
34 template<typename B, typename ... Bs> struct conjunction<B, Bs...> : std::conditional<bool(B::value), conjunction<Bs...>, B>::type {};
35 
36 template<typename ... > struct disjunction : std::true_type {};
37 template<typename B > struct disjunction<B> : B {};
38 template<typename B, typename ... Bs> struct disjunction<B, Bs...> : std::conditional<bool(B::value), disjunction<Bs...>, B>::type {};
39 
40 template <bool B> using bool_constant = std::integral_constant<bool, B>;
41 
42 template<typename B> struct negation : bool_constant<not bool(B::value)> {};
43 
44 #else
45 
46 template <typename ... Bs> using conjunction = std::conjunction<Bs...>;
47 template <typename ... Bs> using disjunction = std::disjunction<Bs...>;
48 template <bool B> using bool_constant = std::bool_constant<B>;
49 template <bool B> using negation = std::negation<B>;
50 
51 
52 #endif
53 
54 
55 template<typename T, typename... Ts>
57 
58 /*
59 template<typename T, typename First>
60 struct is_any_of<T, First>
61  : std::is_same<T, First> {};
62 
63 template<typename T, typename T1, typename T2>
64 struct is_any_of<T, T1, T2>
65  : bool_constant<std::is_same<T, T1>::value or std::is_same<T, T2>::value> {};
66 
67 template<typename T, typename T1, typename T2, typename T3>
68 struct is_any_of<T, T1, T2, T3>
69  : bool_constant<std::is_same<T, T1>::value or std::is_same<T, T2>::value or std::is_same<T, T2>::value> {};
70 
71 template<typename T, typename T1, typename T2, typename T3, typename... Rest>
72 struct is_any_of<T, T1, T2, T3, Rest...>
73  : bool_constant<std::is_same<T, T1, T2, T3>::value or is_any_of<T, Rest...>::value> {};
74 */
75 
76 } // namespace kat
77 
78 #endif // CUDA_KAT_COMMON_HPP_
Definition: common.hpp:36
Definition: common.hpp:16
Definition: common.hpp:42
Definition: common.hpp:32