mimic++ v10.0.1
Loading...
Searching...
No Matches
Call.hpp
Go to the documentation of this file.
1// Copyright Dominic (DNKpp) Koepke 2024-2026.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// https://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef MIMICPP_CALL_HPP
7#define MIMICPP_CALL_HPP
8
9#pragma once
10
11#include "mimic++/Fwd.hpp"
15
16#ifndef MIMICPP_DETAIL_IS_MODULE
17 #include <cstddef>
18 #include <functional>
19 #include <tuple>
20 #include <type_traits>
21#endif
22
24{
25 template <typename Return, typename... Args>
26 class Info
27 {
28 public:
29 using ArgListT = std::tuple<std::reference_wrapper<std::remove_reference_t<Args>>...>;
30
35 std::size_t baseStacktraceSkip{};
36 };
37
38 template <typename Signature>
41 : public info_for_signature<signature_decay_t<Signature>>
43 {
44 };
45
46 template <typename Signature>
48
49 template <typename Return, typename... Args>
50 struct info_for_signature<Return(Args...)>
51 {
52 using type = Info<Return, Args...>;
53 };
54
55 template <typename Result>
57 {
58 public:
59 [[nodiscard]]
60 explicit constexpr ResultStorage(Result&& value) noexcept(std::is_nothrow_move_constructible_v<Result>)
61 : m_Value{std::move(value)}
62 {
63 }
64
65 [[nodiscard]]
66 constexpr Result extract() noexcept(std::is_nothrow_move_constructible_v<Result>)
67 {
68 return std::move(m_Value);
69 }
70
71 private:
72 Result m_Value;
73 };
74
75 template <>
76 class ResultStorage<void>
77 {
78 public:
79 static constexpr void extract() noexcept
80 {
81 }
82 };
83
84 template <typename Result>
85 requires std::is_reference_v<Result>
86 class ResultStorage<Result>
87 {
88 public:
89 using ref = std::reference_wrapper<std::remove_reference_t<Result>>;
90
91 [[nodiscard]]
92 explicit constexpr ResultStorage(ref const ref) noexcept
93 : m_Ref{ref}
94 {
95 }
96
97 [[nodiscard]]
98 constexpr Result&& extract() noexcept
99 {
100 return std::forward<Result>(m_Ref.get());
101 }
102
103 private:
104 ref m_Ref;
105 };
106}
107
108#endif
Definition Call.hpp:27
ValueCategory fromCategory
Definition Call.hpp:32
util::SourceLocation fromSourceLocation
Definition Call.hpp:34
std::size_t baseStacktraceSkip
Definition Call.hpp:35
ArgListT args
Definition Call.hpp:31
std::tuple< std::reference_wrapper< std::remove_reference_t< Args > >... > ArgListT
Definition Call.hpp:29
Constness fromConstness
Definition Call.hpp:33
std::reference_wrapper< std::remove_reference_t< Result > > ref
Definition Call.hpp:89
constexpr Result && extract() noexcept
Definition Call.hpp:98
constexpr ResultStorage(ref const ref) noexcept
Definition Call.hpp:92
static constexpr void extract() noexcept
Definition Call.hpp:79
constexpr Result extract() noexcept(std::is_nothrow_move_constructible_v< Result >)
Definition Call.hpp:66
constexpr ResultStorage(Result &&value) noexcept(std::is_nothrow_move_constructible_v< Result >)
Definition Call.hpp:60
A thin wrapper around general source-location info.
Definition SourceLocation.hpp:33
Definition Call.hpp:24
typename info_for_signature< Signature >::type info_for_signature_t
Definition Call.hpp:47
ValueCategory
Definition Fwd.hpp:34
Constness
Definition Fwd.hpp:27
Info< Return, Args... > type
Definition Call.hpp:52
Definition Call.hpp:43