libcopp 2.3.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
stackful_channel_common.h
Go to the documentation of this file.
1// Copyright 2025 owent
2
3#pragma once
4
6#include <libcopp/utils/config/libcopp_build_features.h>
7
10
11// clang-format off
12#include <libcopp/utils/config/stl_include_prefix.h> // NOLINT(build/include_order)
13// clang-format on
14
15#include <type_traits>
16
17// clang-format off
18#include <libcopp/utils/config/stl_include_suffix.h> // NOLINT(build/include_order)
19// clang-format on
20
21LIBCOPP_COPP_NAMESPACE_BEGIN
22
24
25template <class TVALUE, bool STATIC_CAST, bool IS_POINTER>
26struct LIBCOPP_COPP_API_HEAD_ONLY basic_stackful_channel_error_transform;
27
28template <class TAWAITABLE>
29struct LIBCOPP_COPP_API_HEAD_ONLY stackful_inject_awaitable;
30
31template <class TVALUE>
32struct LIBCOPP_COPP_API_HEAD_ONLY basic_stackful_channel_error_transform<TVALUE, true, false> {
33 using value_type = TVALUE;
34
36 return static_cast<value_type>(err_code);
37 }
38};
39
40template <class TVALUE>
41struct LIBCOPP_COPP_API_HEAD_ONLY basic_stackful_channel_error_transform<TVALUE, false, false> {
42 using value_type = TVALUE;
43
45 noexcept(noexcept(std::is_nothrow_constructible<value_type, copp_error_code>::value)) {
46 return value_type{err_code};
47 }
48};
49
50template <class TVALUE, bool STATIC_CAST>
51struct LIBCOPP_COPP_API_HEAD_ONLY basic_stackful_channel_error_transform<TVALUE, STATIC_CAST, true> {
52 using value_type = TVALUE;
53
54 LIBCOPP_UTIL_FORCEINLINE value_type operator()(copp_error_code /*err_code*/) const noexcept { return nullptr; }
55};
56
57template <class TVALUE>
58struct LIBCOPP_COPP_API_HEAD_ONLY stackful_channel_error_transform
60 TVALUE, std::is_enum<TVALUE>::value || std::is_integral<TVALUE>::value, std::is_pointer<TVALUE>::value> {};
61
62template <class TAWAITABLE>
63struct LIBCOPP_COPP_API_HEAD_ONLY stackful_inject_awaitable : ::std::false_type {};
64
65template <class TCONTAINER>
66using container_value_type = typename nostd::remove_cvref_t<TCONTAINER>::value_type;
67
68LIBCOPP_COPP_NAMESPACE_END
#define LIBCOPP_UTIL_FORCEINLINE
copp_error_code
Definition errno.h:11
typename nostd::remove_cvref_t< TCONTAINER >::value_type container_value_type
struct LIBCOPP_COPP_API_HEAD_ONLY basic_stackful_channel_error_transform
LIBCOPP_UTIL_FORCEINLINE value_type operator()(copp_error_code) const noexcept
LIBCOPP_UTIL_FORCEINLINE value_type operator()(copp_error_code err_code) const noexcept(noexcept(std::is_nothrow_constructible< value_type, copp_error_code >::value))
LIBCOPP_UTIL_FORCEINLINE value_type operator()(copp_error_code err_code) const noexcept