mimic++ v6
Loading...
Searching...
No Matches
GeneralPolicies.hpp
Go to the documentation of this file.
1// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
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_POLICIES_GENERAL_POLICIES_HPP
7#define MIMICPP_POLICIES_GENERAL_POLICIES_HPP
8
9#pragma once
10
11#include "mimic++/Fwd.hpp"
12#include "mimic++/Printer.hpp"
13#include "mimic++/Utility.hpp"
14
15#include <cassert>
16
18{
20 {
21 public:
22 template <typename Return, typename... Args>
23 static constexpr void finalize_call(const call::Info<Return, Args...>&) noexcept
24 {
25 }
26 };
27
28 template <ValueCategory expected>
30 {
31 public:
32 static constexpr bool is_satisfied() noexcept
33 {
34 return true;
35 }
36
37 template <typename Return, typename... Args>
38 static constexpr bool matches(const call::Info<Return, Args...>& info) noexcept
39 {
40 return mimicpp::is_matching(info.fromCategory, expected);
41 }
42
43 template <typename Return, typename... Args>
44 static constexpr void consume([[maybe_unused]] const call::Info<Return, Args...>& info) noexcept
45 {
46 assert(mimicpp::is_matching(info.fromCategory, expected) && "Call does not match.");
47 }
48
49 [[nodiscard]]
51 {
52 return format::format(
53 "expect: from {} category overload",
54 expected);
55 }
56 };
57
58 template <Constness constness>
60 {
61 public:
62 static constexpr bool is_satisfied() noexcept
63 {
64 return true;
65 }
66
67 template <typename Return, typename... Args>
68 static constexpr bool matches(const call::Info<Return, Args...>& info) noexcept
69 {
70 return mimicpp::is_matching(info.fromConstness, constness);
71 }
72
73 template <typename Return, typename... Args>
74 static constexpr void consume([[maybe_unused]] const call::Info<Return, Args...>& info) noexcept
75 {
76 assert(mimicpp::is_matching(info.fromConstness, constness) && "Call does not match.");
77 }
78
79 [[nodiscard]]
81 {
82 return format::format(
83 "expect: from {} qualified overload",
84 constness);
85 }
86 };
87}
88
89#endif
Definition Fwd.hpp:19
Definition GeneralPolicies.hpp:30
static constexpr bool is_satisfied() noexcept
Definition GeneralPolicies.hpp:32
static constexpr void consume(const call::Info< Return, Args... > &info) noexcept
Definition GeneralPolicies.hpp:44
static StringT describe()
Definition GeneralPolicies.hpp:50
static constexpr bool matches(const call::Info< Return, Args... > &info) noexcept
Definition GeneralPolicies.hpp:38
Definition GeneralPolicies.hpp:60
static constexpr bool is_satisfied() noexcept
Definition GeneralPolicies.hpp:62
static constexpr void consume(const call::Info< Return, Args... > &info) noexcept
Definition GeneralPolicies.hpp:74
static constexpr bool matches(const call::Info< Return, Args... > &info) noexcept
Definition GeneralPolicies.hpp:68
static StringT describe()
Definition GeneralPolicies.hpp:80
Definition GeneralPolicies.hpp:20
static constexpr void finalize_call(const call::Info< Return, Args... > &) noexcept
Definition GeneralPolicies.hpp:23
Definition ArgRequirementPolicies.hpp:22
constexpr bool is_matching(const Constness lhs, const Constness rhs) noexcept
Definition Utility.hpp:109
std::basic_string< CharT, CharTraitsT > StringT
Definition Fwd.hpp:344