libcopp  2.2.0
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 
20 #include "libcopp/utils/gsl/span.h"
21 
22 #if defined(LIBCOPP_MACRO_ENABLE_STD_COROUTINE) && LIBCOPP_MACRO_ENABLE_STD_COROUTINE
23 
24 LIBCOPP_COPP_NAMESPACE_BEGIN
25 
26 template <class TFUTURE>
27 struct LIBCOPP_COPP_API_HEAD_ONLY some_ready {
28  using element_type = gsl::not_null<TFUTURE*>;
29  using type = std::vector<element_type>;
30 };
31 
32 template <class TFUTURE>
33 struct 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 
38 template <class TFUTURE>
39 struct 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 
44 template <class TELEMENT>
45 struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper;
46 
47 template <class TELEMENT>
48 struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper<std::reference_wrapper<TELEMENT>> {
49  using type = TELEMENT;
50 };
51 
52 template <class TELEMENT>
53 struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper<gsl::not_null<TELEMENT*>> {
54  using type = TELEMENT;
55 };
56 
57 template <class TELEMENT>
58 struct LIBCOPP_COPP_API_HEAD_ONLY some_ready_remove_wrapper {
59  using type = TELEMENT;
60 };
61 
62 template <class TCONTAINER>
63 struct 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 
73 template <class TELEMENT>
74 struct LIBCOPP_COPP_API_HEAD_ONLY pick_some_reference;
75 
76 template <class TELEMENT>
77 struct 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 
82 template <class TELEMENT>
83 struct 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 
88 template <class TELEMENT>
89 struct 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 
94 LIBCOPP_COPP_NAMESPACE_END
95 
96 #endif
Definition: not_null.h:23
std::shared_ptr< cli::cmd_option_value > value_type
Definition: cmd_option.h:50