Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
async_traits.hpp
Go to the documentation of this file.
1
7#pragma once
8
9#include <concepts>
10#include <type_traits>
11#include <utility>
12
13namespace uni20::async
14{
15
16template <typename T> class Async;
17
19template <typename T> struct async_value_type
20{
21 using type = T;
22};
23
24template <typename T> struct async_value_type<Async<T>>
25{
26 using type = T;
27};
28
30template <typename T> using async_value_t = typename async_value_type<std::remove_cvref_t<T>>::type;
31
32namespace detail
33{
34
35template <typename T, typename = void> struct default_is_async_alias : std::false_type
36{};
37
38template <typename T>
39struct default_is_async_alias<T, std::void_t<typename std::remove_cvref_t<T>::async_alias_tag>> : std::true_type
40{};
41
42} // namespace detail
43
49template <typename T> struct is_async_alias : detail::default_is_async_alias<std::remove_cvref_t<T>>
50{};
51
53template <typename T> inline constexpr bool is_async_alias_v = is_async_alias<std::remove_cvref_t<T>>::value;
54
55namespace detail
56{
57
58// Poison ordinary lookup so only an ADL-visible write-through operation can
59// make an alias assignable.
60void assign_through() = delete;
61
62template <typename Target, typename Source>
63concept async_alias_assignable_from = is_async_alias_v<Target> && requires(Target& target, Source&& source) {
64 { assign_through(target, std::forward<Source>(source)) } -> std::same_as<void>;
65};
66
67template <typename Target, typename Source>
68concept async_alias_assignment_source = async_alias_assignable_from<Target, async_value_t<Source> const&>;
69
70template <typename Target, typename Source>
71 requires async_alias_assignable_from<Target, Source>
72void assign_async_alias(Target& target, Source&& source)
73{
74 assign_through(target, std::forward<Source>(source));
75}
76
77} // namespace detail
78} // namespace uni20::async
Async<T> is a container for coroutine-safe asynchronous read/write.
Definition async/async.hpp:93
locale_t value
Definition data_table.cpp:49
Definition qnum.hpp:403
This represents the reverse-mode adjoint for functions of complex variables, assuming a real-valued s...
Definition async/async.hpp:26
typename async_value_type< std::remove_cvref_t< T > >::type async_value_t
Extract the underlying value type from an immediate value or Async<T>.
Definition async_traits.hpp:30
constexpr bool is_async_alias_v
True when T is an owner-bound async alias descriptor.
Definition async_traits.hpp:53
T type
Definition async_traits.hpp:26
Strip Async<T> to T for assignment and expression type deduction.
Definition async_traits.hpp:20
T type
Definition async_traits.hpp:21
Identifies payload descriptors requiring shared async alias identity.
Definition async_traits.hpp:50