libcopp 2.3.1
Loading...
Searching...
No Matches
algorithm_common.h
Go to the documentation of this file.
1// Copyright 2023 owent
2
3#pragma once
4
5#include <libcopp/utils/config/libcopp_build_features.h>
6
7// clang-format off
8#include <libcopp/utils/config/stl_include_prefix.h> // NOLINT(build/include_order)
9// clang-format on
10#include <assert.h>
11#include <list>
12#include <type_traits>
13#include <vector>
14// clang-format off
15#include <libcopp/utils/config/stl_include_suffix.h> // NOLINT(build/include_order)
16// clang-format on
17
21
22#if defined(LIBCOPP_MACRO_ENABLE_STD_COROUTINE) && LIBCOPP_MACRO_ENABLE_STD_COROUTINE
23
24LIBCOPP_COPP_NAMESPACE_BEGIN
25
26template <class TFUTURE>
27struct LIBCOPP_COPP_API_HEAD_ONLY some_ready {
28 using element_type = gsl::not_null<TFUTURE*>;
29 using type = std::vector<element_type>;
30};
31
32template <class TFUTURE>
33struct LIBCOPP_COPP_API_HEAD_ONLY any_ready {
34 using element_type = typename some_ready<TFUTURE>::element_type;
35 using type = typename some_ready<TFUTURE>::type;
36};
37
38template <class TFUTURE>
39struct LIBCOPP_COPP_API_HEAD_ONLY all_ready {
40 using element_type = typename some_ready<TFUTURE>::element_type;
41 using type = typename some_ready<TFUTURE>::type;
42};
43
44template <class TELEMENT>
45struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper;
46
47template <class TELEMENT>
48struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper<std::reference_wrapper<TELEMENT>> {
49 using type = TELEMENT;
50};
51
52template <class TELEMENT>
53struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper<gsl::not_null<TELEMENT*>> {
54 using type = TELEMENT;
55};
56
57template <class TELEMENT>
58struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper {
59 using type = TELEMENT;
60};
61
62template <class TCONTAINER>
63struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_container {
64 using container_type = typename std::decay<TCONTAINER>::type;
65 using value_type =
66 typename std::decay<typename some_ready_remove_wrapper<typename container_type::value_type>::type>::type;
67 using reference_type = value_type&;
68 using const_reference_type = const value_type&;
69 using pointer_type = value_type*;
70 using const_pointer_type = const value_type*;
71};
72
73template <class TELEMENT>
74struct LIBCOPP_COPP_API_HEAD_ONLY pick_some_reference;
75
76template <class TELEMENT>
77struct LIBCOPP_COPP_API_HEAD_ONLY pick_some_reference<std::reference_wrapper<TELEMENT>> {
78 inline static TELEMENT& unwrap(std::reference_wrapper<TELEMENT>& input) noexcept { return input.get(); }
79 inline static const TELEMENT& unwrap(std::reference_wrapper<const TELEMENT>& input) noexcept { return input.get(); }
80};
81
82template <class TELEMENT>
83struct LIBCOPP_COPP_API_HEAD_ONLY pick_some_reference<gsl::not_null<TELEMENT*>> {
84 inline static TELEMENT& unwrap(gsl::not_null<TELEMENT*>& input) noexcept { return *input.get(); }
85 inline static const TELEMENT& unwrap(gsl::not_null<const TELEMENT*>& input) noexcept { return *input.get(); }
86};
87
88template <class TELEMENT>
89struct LIBCOPP_COPP_API_HEAD_ONLY pick_some_reference {
90 inline static TELEMENT& unwrap(TELEMENT& input) noexcept { return input; }
91 inline static const TELEMENT& unwrap(const TELEMENT& input) noexcept { return input; }
92};
93
94LIBCOPP_COPP_NAMESPACE_END
95
96#endif
Definition not_null.h:23
STL namespace.
std::shared_ptr< cli::cmd_option_value > value_type
Definition cmd_option.h:50