1+ // Copyright (c) The Bitcoin Core developers
2+ // Distributed under the MIT software license, see the accompanying
3+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+ #ifndef MP_PROXY_TYPE_UNORDERED_SET_H
6+ #define MP_PROXY_TYPE_UNORDERED_SET_H
7+
8+ #include < mp/proxy-types.h>
9+ #include < mp/util.h>
10+ #include < unordered_set>
11+
12+ namespace mp {
13+ template <typename LocalType, typename Value, typename Output>
14+ void CustomBuildField (TypeList<std::unordered_set<LocalType>>,
15+ Priority<1 >,
16+ InvokeContext& invoke_context,
17+ Value&& value,
18+ Output&& output)
19+ {
20+ BuildList (TypeList<LocalType>(), invoke_context, output, value);
21+ }
22+
23+ template <typename LocalType, typename Input, typename ReadDest>
24+ decltype (auto ) CustomReadField(TypeList<std::unordered_set<LocalType>>,
25+ Priority<1 >,
26+ InvokeContext& invoke_context,
27+ Input&& input,
28+ ReadDest&& read_dest)
29+ {
30+ return read_dest.update ([&](auto & value) {
31+ auto data = input.get ();
32+ value.clear ();
33+ for (auto item : data) {
34+ ReadField (TypeList<LocalType>(), invoke_context, Make<ValueField>(item),
35+ ReadDestEmplace (TypeList<const LocalType>(), [&](auto &&... args) -> auto & {
36+ return *value.emplace (std::forward<decltype (args)>(args)...).first ;
37+ }));
38+ }
39+ });
40+ }
41+ } // namespace mp
42+
43+ #endif // MP_PROXY_TYPE_UNORDERED_SET_H
0 commit comments