blob: 5b84bac90590960b3969b4946a8cd9982aee26b6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#pragma once
#include <concepts>
#include <vector>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
namespace NDetail {
template <class T, class TSignature>
struct TIsInvocable;
template <class T, class TResult, bool NoExcept, class... TArgs>
struct TIsInvocable<T, TResult(TArgs...) noexcept(NoExcept)>
{
private:
static constexpr bool IsInvocable_ = requires (T&& t, TArgs&&... args) {
{ std::forward<T>(t)(std::forward<TArgs>(args)...) } -> std::same_as<TResult>;
};
static constexpr bool IsNoThrowInvocable_ = requires (T&& t, TArgs&&... args) {
{ std::forward<T>(t)(std::forward<TArgs>(args)...) } noexcept -> std::same_as<TResult>;
};
public:
static constexpr bool Value =
IsInvocable_ &&
(!NoExcept || IsNoThrowInvocable_);
};
} // namespace NDetail
////////////////////////////////////////////////////////////////////////////////
template <class TObject, class TScalar>
concept CScalable = requires (TObject object, TScalar scalar)
{
{ object * scalar } -> std::same_as<TObject>;
};
////////////////////////////////////////////////////////////////////////////////
template <class T, class TSignature>
concept CInvocable = NDetail::TIsInvocable<T, TSignature>::Value;
////////////////////////////////////////////////////////////////////////////////
template <class V>
concept CStdVector = requires (V& vec) {
[] <class... T> (std::vector<T...>&) { } (vec);
};
////////////////////////////////////////////////////////////////////////////////
template <class M>
concept CAnyMap = requires {
typename M::mapped_type;
typename M::key_type;
};
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|