mimic++
v10.0.1
Toggle main menu visibility
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
"
12
#include "
mimic++/TypeTraits.hpp
"
13
#include "
mimic++/utilities/SourceLocation.hpp
"
14
#include "
mimic++/utilities/Stacktrace.hpp
"
15
16
#ifndef MIMICPP_DETAIL_IS_MODULE
17
#include <cstddef>
18
#include <functional>
19
#include <tuple>
20
#include <type_traits>
21
#endif
22
23
namespace
mimicpp::call
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
31
ArgListT
args
;
32
ValueCategory
fromCategory
{};
33
Constness
fromConstness
{};
34
util::SourceLocation
fromSourceLocation
{};
35
std::size_t
baseStacktraceSkip
{};
36
};
37
38
template
<
typename
Signature>
39
struct
info_for_signature
41
:
public
info_for_signature
<signature_decay_t<Signature>>
43
{
44
};
45
46
template
<
typename
Signature>
47
using
info_for_signature_t
=
typename
info_for_signature<Signature>::type
;
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>
56
class
ResultStorage
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
Fwd.hpp
SourceLocation.hpp
Stacktrace.hpp
TypeTraits.hpp
mimicpp::call::Info
Definition
Call.hpp:27
mimicpp::call::Info< Return, Args... >::fromCategory
ValueCategory fromCategory
Definition
Call.hpp:32
mimicpp::call::Info< Return, Args... >::fromSourceLocation
util::SourceLocation fromSourceLocation
Definition
Call.hpp:34
mimicpp::call::Info< Return, Args... >::baseStacktraceSkip
std::size_t baseStacktraceSkip
Definition
Call.hpp:35
mimicpp::call::Info< Return, Args... >::args
ArgListT args
Definition
Call.hpp:31
mimicpp::call::Info::ArgListT
std::tuple< std::reference_wrapper< std::remove_reference_t< Args > >... > ArgListT
Definition
Call.hpp:29
mimicpp::call::Info< Return, Args... >::fromConstness
Constness fromConstness
Definition
Call.hpp:33
mimicpp::call::ResultStorage< Result >::ref
std::reference_wrapper< std::remove_reference_t< Result > > ref
Definition
Call.hpp:89
mimicpp::call::ResultStorage< Result >::extract
constexpr Result && extract() noexcept
Definition
Call.hpp:98
mimicpp::call::ResultStorage< Result >::ResultStorage
constexpr ResultStorage(ref const ref) noexcept
Definition
Call.hpp:92
mimicpp::call::ResultStorage< void >::extract
static constexpr void extract() noexcept
Definition
Call.hpp:79
mimicpp::call::ResultStorage::extract
constexpr Result extract() noexcept(std::is_nothrow_move_constructible_v< Result >)
Definition
Call.hpp:66
mimicpp::call::ResultStorage::ResultStorage
constexpr ResultStorage(Result &&value) noexcept(std::is_nothrow_move_constructible_v< Result >)
Definition
Call.hpp:60
mimicpp::util::SourceLocation
A thin wrapper around general source-location info.
Definition
SourceLocation.hpp:33
mimicpp::call
Definition
Call.hpp:24
mimicpp::call::info_for_signature_t
typename info_for_signature< Signature >::type info_for_signature_t
Definition
Call.hpp:47
mimicpp::ValueCategory
ValueCategory
Definition
Fwd.hpp:34
mimicpp::Constness
Constness
Definition
Fwd.hpp:27
mimicpp::call::info_for_signature< Return(Args...)>::type
Info< Return, Args... > type
Definition
Call.hpp:52
mimicpp::call::info_for_signature
Definition
Call.hpp:43
mimic++
Call.hpp
Generated on
for mimic++ by
1.18.0