Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Concepts.hpp
1
#pragma once
2
3
#include <algorithm>
4
#include <array>
5
#include <chrono>
6
#include <concepts>
7
#include <cstddef>
8
#include <string_view>
9
#include <type_traits>
10
11
namespace
util
{
12
18
template
<
typename
T>
19
concept
SomeNumberType
= std::is_arithmetic_v<T> && !std::is_same_v<T, bool> && !std::is_const_v<T>;
20
26
template
<
typename
T>
27
concept
SomeSystemClock
=
requires
{
28
{ T::now() } -> std::same_as<std::chrono::system_clock::time_point>;
29
};
30
37
static
consteval
auto
38
hasNoDuplicates
(
auto
&&... values)
39
{
40
auto
store = std::array{values...};
41
auto
end = store.end();
42
std::ranges::sort(store);
43
return
(std::unique(std::begin(store), end) == end);
44
}
45
52
template
<
typename
... Types>
53
constexpr
bool
54
hasNoDuplicateNames
()
55
{
56
constexpr
std::array<std::string_view,
sizeof
...(Types)> kNames = {Types::kName...};
57
return
!std::ranges::any_of(kNames, [&](std::string_view
const
& name1) {
58
return
std::ranges::any_of(kNames, [&](std::string_view
const
& name2) {
59
return
&name1 != &name2 && name1 == name2;
// Ensure different elements are compared
60
});
61
});
62
}
63
64
}
// namespace util
util::SomeNumberType
Specifies a number type.
Definition
Concepts.hpp:19
util::SomeSystemClock
Specifies a clock that reports the current time as a system clock time point.
Definition
Concepts.hpp:27
util
This namespace contains various utilities.
Definition
HandlerRegistry.hpp:24
util::hasNoDuplicates
static consteval auto hasNoDuplicates(auto &&... values)
Checks that the list of given values contains no duplicates.
Definition
Concepts.hpp:38
util::hasNoDuplicateNames
constexpr bool hasNoDuplicateNames()
Checks that the list of given type contains no duplicates.
Definition
Concepts.hpp:54
src
util
Concepts.hpp
Generated by
1.17.0