21 #ifndef __TBB_template_helpers_H 22 #define __TBB_template_helpers_H 29 template<
bool Condition,
typename T =
void>
struct enable_if {};
30 template<
typename T>
struct enable_if<true, T> {
typedef T type; };
33 template<
typename T>
struct strip {
typedef T type; };
34 template<
typename T>
struct strip<const T> {
typedef T type; };
35 template<
typename T>
struct strip<volatile T> {
typedef T type; };
36 template<
typename T>
struct strip<const volatile T> {
typedef T type; };
37 template<
typename T>
struct strip<T&> {
typedef T type; };
38 template<
typename T>
struct strip<const T&> {
typedef T type; };
39 template<
typename T>
struct strip<volatile T&> {
typedef T type; };
40 template<
typename T>
struct strip<const volatile T&> {
typedef T type; };
42 template<
typename T>
struct strip<T(&)()> {
typedef T(*type)(); };
43 #if __TBB_CPP11_RVALUE_REF_PRESENT 44 template<
typename T>
struct strip<T&&> {
typedef T type; };
45 template<
typename T>
struct strip<const T&&> {
typedef T type; };
46 template<
typename T>
struct strip<volatile T&&> {
typedef T type; };
47 template<
typename T>
struct strip<const volatile T&&> {
typedef T type; };
49 template<
typename T,
size_t N>
struct strip<T(&)[N]> {
typedef T* type; };
51 template<
typename T,
size_t N>
struct strip<const T(&)[N]> {
typedef const T* type; };
52 template<
typename T,
size_t N>
struct strip<volatile T(&)[N]> {
typedef volatile T* type; };
53 template<
typename T,
size_t N>
struct strip<const volatile T(&)[N]> {
typedef const volatile T* type; };
56 template<
class U,
class V>
struct is_same_type {
static const bool value =
false; };
57 template<
class W>
struct is_same_type<W,W> {
static const bool value =
true; };
59 template<
typename T>
struct is_ref {
static const bool value =
false; };
60 template<
typename U>
struct is_ref<U&> {
static const bool value =
true; };
62 #if __TBB_CPP11_RVALUE_REF_PRESENT && __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 65 template<
typename... Types >
71 typedef stored_pack<> pack_type;
75 template<
typename F,
typename Pack >
friend void call( F&& f, Pack&& p );
76 template<
typename Ret,
typename F,
typename Pack >
friend Ret call_and_return( F&& f, Pack&& p );
81 template<
typename Ret,
typename F,
typename... Preceding >
82 static Ret call( F&& f,
const pack_type& , Preceding&&... params ) {
83 return std::forward<F>(f)( std::forward<Preceding>(params)... );
85 template<
typename Ret,
typename F,
typename... Preceding >
86 static Ret call( F&& f, pack_type&& , Preceding&&... params ) {
87 return std::forward<F>(f)( std::forward<Preceding>(params)... );
91 template<
typename T,
typename... Types >
92 struct stored_pack<T, Types...> : stored_pack<Types...>
94 typedef stored_pack<T, Types...> pack_type;
95 typedef stored_pack<Types...> pack_remainder;
98 typename strip<T>::type leftmost_value;
102 stored_pack( T&& t, Types&&... types )
103 : pack_remainder(std::forward<Types>(types)...), leftmost_value(std::forward<T>(t)) {}
106 template<
typename F,
typename Pack >
friend void call( F&& f, Pack&& p );
107 template<
typename Ret,
typename F,
typename Pack >
friend Ret call_and_return( F&& f, Pack&& p );
110 template<
typename Ret,
typename F,
typename... Preceding >
111 static Ret call( F&& f,
const pack_type& pack, Preceding&&... params ) {
112 return pack_remainder::template call<Ret>(
113 std::forward<F>(f), static_cast<const pack_remainder&>(pack),
114 std::forward<Preceding>(params)... , pack.leftmost_value
117 template<
typename Ret,
typename F,
typename... Preceding >
118 static Ret call( F&& f, pack_type&& pack, Preceding&&... params ) {
119 return pack_remainder::template call<Ret>(
120 std::forward<F>(f), static_cast<pack_remainder&&>(pack),
121 std::forward<Preceding>(params)... , std::move(pack.leftmost_value)
127 template<
typename F,
typename Pack >
128 void call( F&& f, Pack&& p ) {
132 template<
typename Ret,
typename F,
typename Pack >
133 Ret call_and_return( F&& f, Pack&& p ) {
137 template<
typename... Types >
138 stored_pack<Types...> save_pack( Types&&... types ) {
139 return stored_pack<Types...>( std::forward<Types>(types)... );
Enables one or the other code branches.
Definition: _template_helpers.h:29
Detects whether two given types are the same.
Definition: _template_helpers.h:56
Definition: _template_helpers.h:59
Definition: _flow_graph_async_msg_impl.h:32
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
Strips its template type argument from cv- and ref-qualifiers.
Definition: _template_helpers.h:33