YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
type_traits.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <yaclib/fwd.hpp>
5
6#include <exception>
7#include <type_traits>
8#include <utility>
9
10namespace yaclib {
11
12template <typename... Args>
13using head_t = typename detail::Head<Args...>::Type; // NOLINT
14
15template <typename Func, typename... Arg>
16inline constexpr bool is_invocable_v = detail::IsInvocable<Func, Arg...>::Value; // NOLINT
17
18template <typename Func, typename... Arg>
19using invoke_t = typename detail::Invoke<Func, Arg...>::Type; // NOLINT
20
21template <typename T>
23
24template <typename T>
26
27template <typename T>
29
30template <typename T>
32
33template <typename T>
35
36template <typename T>
40template <typename T>
41inline constexpr bool is_task_v = detail::IsInstantiationOf<Task, T>::Value; // NOLINT
42
43template <typename T>
45
46template <typename T>
48
49template <bool Condition, typename T>
50decltype(auto) move_if(T&& arg) noexcept { // NOLINT
51 if constexpr (Condition) {
52 return std::move(std::forward<T>(arg));
53 } else {
54 return std::forward<T>(arg);
55 }
56}
57
58template <typename T>
59constexpr bool Check() noexcept {
60 static_assert(!std::is_reference_v<T>, "T cannot be V&, just use pointer or std::reference_wrapper");
61 static_assert(!std::is_const_v<T>, "T cannot be const, because it's unnecessary");
62 static_assert(!std::is_volatile_v<T>, "T cannot be volatile, because it's unnecessary");
63 static_assert(!is_result_v<T>, "T cannot be Result, because it's ambiguous");
64 static_assert(!is_future_base_v<T>, "T cannot be Future, because it's ambiguous");
65 static_assert(!is_task_v<T>, "T cannot be Task, because it's ambiguous");
66 static_assert(!std::is_same_v<T, std::exception_ptr>, "T cannot be std::exception_ptr, because it's ambiguous");
67 static_assert(!std::is_same_v<T, Unit>, "T cannot be Unit, because Unit for internal instead of void usage");
68 return true;
69}
70
71} // namespace yaclib
typename detail::FutureBaseTypes< T >::Value future_base_value_t
typename detail::InstantiationTypes< Task, T >::Error task_error_t
typename detail::Head< Args... >::Type head_t
constexpr bool is_result_v
constexpr bool is_task_v
constexpr bool is_invocable_v
decltype(auto) move_if(T &&arg) noexcept
constexpr bool is_future_base_v
typename detail::FutureBaseTypes< T >::Error future_base_error_t
constexpr bool Check() noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25
typename detail::Invoke< Func, Arg... >::Type invoke_t
typename detail::InstantiationTypes< Task, T >::Value task_value_t
typename detail::InstantiationTypes< Result, T >::Value result_value_t
typename detail::InstantiationTypes< Result, T >::Error result_error_t