Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Concepts.hpp
1#pragma once
2
3#include <algorithm>
4#include <array>
5#include <cstddef>
6#include <string_view>
7#include <type_traits>
8
9namespace util {
10
14template <typename T>
15concept SomeNumberType = std::is_arithmetic_v<T> && !std::is_same_v<T, bool> && !std::is_const_v<T>;
16
23static consteval auto
24hasNoDuplicates(auto&&... values)
25{
26 auto store = std::array{values...};
27 auto end = store.end();
28 std::ranges::sort(store);
29 return (std::unique(std::begin(store), end) == end);
30}
31
38template <typename... Types>
39constexpr bool
41{
42 constexpr std::array<std::string_view, sizeof...(Types)> kNAMES = {Types::kNAME...};
43 return !std::ranges::any_of(kNAMES, [&](std::string_view const& name1) {
44 return std::ranges::any_of(kNAMES, [&](std::string_view const& name2) {
45 return &name1 != &name2 && name1 == name2; // Ensure different elements are compared
46 });
47 });
48}
49
50} // namespace util
Specifies a number type.
Definition Concepts.hpp:15
This namespace contains various utilities.
Definition AccountUtils.hpp:11
static consteval auto hasNoDuplicates(auto &&... values)
Checks that the list of given values contains no duplicates.
Definition Concepts.hpp:24
constexpr bool hasNoDuplicateNames()
Checks that the list of given type contains no duplicates.
Definition Concepts.hpp:40