mimic++
v10.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
Concepts.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_UTILITIES_CONCEPTS_HPP
7
#define MIMICPP_UTILITIES_CONCEPTS_HPP
8
9
#pragma once
10
11
#include "
mimic++/config/Config.hpp
"
12
13
#ifndef MIMICPP_DETAIL_IS_MODULE
14
#include <concepts>
15
#include <utility>
16
#endif
17
18
MIMICPP_DETAIL_MODULE_EXPORT
namespace
mimicpp::util
19
{
27
33
template
<
typename
From,
typename
To>
34
concept
explicitly_convertible_to
=
35
requires
{
36
static_cast<
To
>
(std::declval<From>());
37
};
38
42
template
<
typename
From,
typename
To>
43
concept
nothrow_explicitly_convertible_to
=
44
explicitly_convertible_to<From, To>
45
&&
requires
{
46
{
static_cast<
To
>
(std::declval<From>()) }
noexcept
;
47
};
48
52
template
<
typename
T,
typename
... Others>
53
concept
same_as_any
= (... || std::same_as<T, Others>);
54
58
template
<
typename
T,
template
<
typename
>
typename
Trait>
59
concept
satisfies
= Trait<T>::value;
60
65
template
<
typename
B>
66
concept
boolean_testable
=
67
std::convertible_to<B, bool>
68
&&
requires
(B&& b) {
69
{ !std::forward<B>(b) } -> std::convertible_to<bool>;
70
};
71
77
template
<
typename
T,
typename
U>
78
concept
weakly_equality_comparable_with
=
79
requires
(std::remove_reference_t<T>
const
& t, std::remove_reference_t<U>
const
& u) {
80
{ t == u } ->
boolean_testable
;
81
{ t != u } ->
boolean_testable
;
82
{ u == t } ->
boolean_testable
;
83
{ u != t } ->
boolean_testable
;
84
};
85
89
template
<
typename
T>
90
concept
unqualified
= std::same_as<T, std::remove_cvref_t<T>>;
91
95
}
96
97
#endif
Config.hpp
MIMICPP_DETAIL_MODULE_EXPORT
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition
Config.hpp:19
mimicpp::util::boolean_testable
Determines, whether B behaves as a the builtin type bool.
Definition
Concepts.hpp:66
mimicpp::util::explicitly_convertible_to
Determines, whether From can be explicitly converted to To.
Definition
Concepts.hpp:34
mimicpp::util::nothrow_explicitly_convertible_to
Determines, whether From can be explicitly converted to To, without throwing.
Definition
Concepts.hpp:43
mimicpp::util::same_as_any
Determines, whether T is the same as any type of the pack Others.
Definition
Concepts.hpp:53
mimicpp::util::satisfies
Determines, whether T satisfies the specified trait type.
Definition
Concepts.hpp:59
mimicpp::util::unqualified
Determines, whether T is unqualified.
Definition
Concepts.hpp:90
mimicpp::util::weakly_equality_comparable_with
Determines, whether T can be equality compared with U.
Definition
Concepts.hpp:78
mimicpp::util
Definition
Fwd.hpp:451
mimic++
utilities
Concepts.hpp
Generated on
for mimic++ by
1.18.0