mimic++ v9.2.1
Loading...
Searching...
No Matches
Concepts.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_UTILITIES_CONCEPTS_HPP
7#define MIMICPP_UTILITIES_CONCEPTS_HPP
8
9#pragma once
10
12
13#ifndef MIMICPP_DETAIL_IS_MODULE
14 #include <concepts>
15 #include <utility>
16#endif
17
19{
27
33 template <typename From, typename To>
35 requires {
36 static_cast<To>(std::declval<From>());
37 };
38
42 template <typename From, typename 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>
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>
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}
90
91#endif
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition Config.hpp:19
Determines, whether B behaves as a the builtin type bool.
Definition Concepts.hpp:66
Determines, whether From can be explicitly converted to To.
Definition Concepts.hpp:34
Determines, whether From can be explicitly converted to To, without throwing.
Definition Concepts.hpp:43
Determines, whether T is the same as any type of the pack Others.
Definition Concepts.hpp:53
Determines, whether T satisfies the specified trait type.
Definition Concepts.hpp:59
Determines, whether T can be equality compared with U.
Definition Concepts.hpp:78
Definition Fwd.hpp:445