ttg 1.0.0
Template Task Graph (TTG): flowgraph-based programming model for high-performance distributed-memory algorithms
Loading...
Searching...
No Matches
utility.hpp
Go to the documentation of this file.
1/*
2
3@Copyright Barrett Adair 2015-2017
4Distributed under the Boost Software License, Version 1.0.
5(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
6
7*/
8
9#ifndef BOOST_CLBL_TRTS_DETAIL_UTILITY_HPP
10#define BOOST_CLBL_TRTS_DETAIL_UTILITY_HPP
11
15
16namespace boost { namespace callable_traits { namespace detail {
17
18struct cdecl_tag{};
19struct stdcall_tag{};
20struct fastcall_tag{};
21struct pascal_tag{};
22
23struct invalid_type { invalid_type() = delete; };
24struct reference_error { reference_error() = delete; };
25
26template<typename T>
27using error_type = typename std::conditional<
28 std::is_reference<T>::value, reference_error, invalid_type>::type;
29
30#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
31struct abominable_functions_not_supported_on_this_compiler{};
32#endif
33
34// used to convey "this type doesn't matter" in code
35struct dummy {};
36
37// used as return type in failed SFINAE tests
38struct substitution_failure : std::false_type{};
39
40template<bool Value>
41using bool_type = std::integral_constant<bool, Value>;
42
43// shorthand for std::tuple_element
44template<std::size_t I, typename Tup>
45using at = typename std::tuple_element<I, Tup>::type;
46
47template<typename T, typename Class>
48using add_member_pointer = T Class::*;
49
50template<typename L, typename R, typename ErrorType>
52
53template<typename T, typename ErrorType,
54 typename U = typename std::remove_reference<T>::type>
58 reference_type_not_supported_by_this_metafunction>>;
59
60template<typename T, typename ErrorType,
61 typename U = typename std::remove_reference<T>::type,
62 bool is_reference_error = std::is_same<reference_error, U>::value>
64 std::is_same<U, invalid_type>::value || is_reference_error,
65 typename std::conditional<is_reference_error,
66 reference_type_not_supported_by_this_metafunction, ErrorType>::type>;
67
68template<typename T, typename Fallback>
69using fallback_if_invalid = typename std::conditional<
70 std::is_same<T, invalid_type>::value, Fallback, T>::type;
71
72template<typename T, template<class> class Alias, typename U = Alias<T>>
74 using type = U;
75};
76
77template<typename T>
78using shallow_decay = typename std::remove_cv<
79 typename std::remove_reference<T>::type>::type;
80
81template<typename T>
83 using type = std::false_type;
84};
85
86template<typename T>
87struct is_reference_wrapper_t<std::reference_wrapper<T>> {
88 using type = std::true_type;
89};
90
91template<typename T>
94
95template<typename T, typename = std::true_type>
97 using type = T;
98};
99
100template<typename T>
102 using type = decltype(std::declval<T>().get());
103};
104
105// removes std::reference_wrapper
106template<typename T>
108
109}}} // namespace boost::callable_traits::detail
110
111#endif // #ifndef BOOST_CLBL_TRTS_DETAIL_UTILITY_HPP
typename std::conditional< std::is_reference< T >::value, reference_error, invalid_type >::type error_type
Definition utility.hpp:28
typename std::tuple_element< I, Tup >::type at
Definition utility.hpp:45
sfinae_try< T, fail_when_same< U, invalid_type, ErrorType >, fail_when_same< U, reference_error, reference_type_not_supported_by_this_metafunction > > try_but_fail_if_invalid
Definition utility.hpp:58
typename std::remove_cv< typename std::remove_reference< T >::type >::type shallow_decay
Definition utility.hpp:79
typename std::conditional< std::is_same< T, invalid_type >::value, Fallback, T >::type fallback_if_invalid
Definition utility.hpp:70
std::integral_constant< bool, Value > bool_type
Definition utility.hpp:41
typename is_reference_wrapper_t< shallow_decay< T > >::type is_reference_wrapper
Definition utility.hpp:93
typename unwrap_reference_t< T >::type unwrap_reference
Definition utility.hpp:107
typename BOOST_CLBL_TRTS_DISJUNCTION(FailIfs..., success< T >)::_::type sfinae_try
STL namespace.