mimic++ v1
Loading...
Searching...
No Matches
Call.hpp
Go to the documentation of this file.
1// // Copyright Dominic (DNKpp) Koepke 2024 - 2024.
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"
13#include "mimic++/Utility.hpp"
14
15#include <source_location>
16#include <tuple>
17#include <utility>
18
19namespace mimicpp::call::detail
20{
21 template <typename... Args, std::size_t... indices>
22 [[nodiscard]]
23 constexpr bool is_equal_param_list(
24 const std::tuple<std::reference_wrapper<Args>...>& lhs,
25 const std::tuple<std::reference_wrapper<Args>...>& rhs,
26 const std::index_sequence<indices...>
27 ) noexcept
28 {
29 return (
30 ...
31 && (std::addressof(
32 std::get<indices>(lhs).get())
33 == std::addressof(
34 std::get<indices>(rhs).get())));
35 }
36}
37
38namespace mimicpp::call
39{
40 template <typename Return, typename... Args>
41 class Info
42 {
43 public:
44 using ArgListT = std::tuple<std::reference_wrapper<std::remove_reference_t<Args>>...>;
45
49 std::source_location fromSourceLocation{};
50
51 [[nodiscard]]
52 friend bool operator ==(const Info& lhs, const Info& rhs)
53 {
54 return lhs.fromCategory == rhs.fromCategory
55 && lhs.fromConstness == rhs.fromConstness
56 && detail::is_equal_param_list(lhs.args, rhs.args, std::index_sequence_for<Args...>{})
57 && is_same_source_location(lhs.fromSourceLocation, rhs.fromSourceLocation);
58 }
59 };
60
61 template <typename Signature>
63 : public info_for_signature<signature_decay_t<Signature>>
64 {
65 };
66
67 template <typename Signature>
69
70 template <typename Return, typename... Args>
71 struct info_for_signature<Return(Args...)>
72 {
73 using type = Info<Return, Args...>;
74 };
75}
76
77#endif
Definition Fwd.hpp:16
ValueCategory fromCategory
Definition Call.hpp:47
friend bool operator==(const Info &lhs, const Info &rhs)
Definition Call.hpp:52
std::source_location fromSourceLocation
Definition Call.hpp:49
ArgListT args
Definition Call.hpp:46
std::tuple< std::reference_wrapper< std::remove_reference_t< Args > >... > ArgListT
Definition Call.hpp:44
Constness fromConstness
Definition Call.hpp:48
Definition Call.hpp:20
typename info_for_signature< Signature >::type info_for_signature_t
Definition Call.hpp:68
constexpr bool is_same_source_location(const std::source_location &lhs, const std::source_location &rhs) noexcept
Definition Utility.hpp:116
ValueCategory
Definition Utility.hpp:35
Constness
Definition Utility.hpp:21
Definition Call.hpp:64