aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/error/mergeable_dictionary.h
blob: cf866f3da7cac3d02cf9323bd4f34d630c49f6f2 (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
#pragma once

#include "error_attribute.h"

#include <library/cpp/yt/memory/type_erasure.h>

#include <library/cpp/yt/misc/tag_invoke_cpo.h>

#include <ranges>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

namespace NMergeableRangeImpl {

struct TFn
    : public TTagInvokeCpoBase<TFn>
{ };

////////////////////////////////////////////////////////////////////////////////

using TMergeableRange = std::vector<std::pair<TErrorAttribute::TKey, TErrorAttribute::TValue>>;

} // namespace NMergeableRangeImpl

////////////////////////////////////////////////////////////////////////////////

// Can be customized to make your dictionary satisfy CMergeableDictionary.
inline constexpr NMergeableRangeImpl::TFn AsMergeableRange = {};

////////////////////////////////////////////////////////////////////////////////

template <class T>
concept CMergeableDictionary = CTagInvocableS<
    TTagInvokeTag<AsMergeableRange>,
    NMergeableRangeImpl::TMergeableRange(const T&)>;

////////////////////////////////////////////////////////////////////////////////

using TAnyMergeableDictionaryRef = TAnyRef<
    TOverload<AsMergeableRange, NMergeableRangeImpl::TMergeableRange(const TErasedThis&)>>;

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT