Skip to content

Commit e834ebd

Browse files
committed
moveonly: add mp/type-decay.h
1 parent 5ee6cd4 commit e834ebd

File tree

5 files changed

+41
-26
lines changed

5 files changed

+41
-26
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(MP_PUBLIC_HEADERS
4747
include/mp/proxy.h
4848
include/mp/type-char.h
4949
include/mp/type-context.h
50+
include/mp/type-decay.h
5051
include/mp/type-exception.h
5152
include/mp/type-function.h
5253
include/mp/type-interface.h

example/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define EXAMPLE_TYPES_H
77

88
#include <mp/type-context.h>
9+
#include <mp/type-decay.h>
910
#include <mp/type-interface.h>
1011
#include <mp/type-string.h>
1112

include/mp/proxy-types.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -205,32 +205,6 @@ struct ListOutput<::capnp::List<T, kind>>
205205
// clang-format on
206206
};
207207

208-
template <typename LocalType, typename Value, typename Output>
209-
void CustomBuildField(TypeList<const LocalType>,
210-
Priority<0>,
211-
InvokeContext& invoke_context,
212-
Value&& value,
213-
Output&& output)
214-
{
215-
BuildField(TypeList<LocalType>(), invoke_context, output, std::forward<Value>(value));
216-
}
217-
218-
template <typename LocalType, typename Value, typename Output>
219-
void CustomBuildField(TypeList<LocalType&>, Priority<0>, InvokeContext& invoke_context, Value&& value, Output&& output)
220-
{
221-
BuildField(TypeList<LocalType>(), invoke_context, output, std::forward<Value>(value));
222-
}
223-
224-
template <typename LocalType, typename Value, typename Output>
225-
void CustomBuildField(TypeList<LocalType&&>,
226-
Priority<0>,
227-
InvokeContext& invoke_context,
228-
Value&& value,
229-
Output&& output)
230-
{
231-
BuildField(TypeList<LocalType>(), invoke_context, output, std::forward<Value>(value));
232-
}
233-
234208
template <typename LocalType, typename Value, typename Output>
235209
void CustomBuildField(TypeList<LocalType>, Priority<0>, InvokeContext& invoke_context, Value&& value, Output&& output)
236210
{

include/mp/type-decay.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2025 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_DECAY_H
6+
#define MP_PROXY_TYPE_DECAY_H
7+
8+
#include <mp/util.h>
9+
10+
namespace mp {
11+
template <typename LocalType, typename Value, typename Output>
12+
void CustomBuildField(TypeList<const LocalType>,
13+
Priority<0>,
14+
InvokeContext& invoke_context,
15+
Value&& value,
16+
Output&& output)
17+
{
18+
BuildField(TypeList<LocalType>(), invoke_context, output, std::forward<Value>(value));
19+
}
20+
21+
template <typename LocalType, typename Value, typename Output>
22+
void CustomBuildField(TypeList<LocalType&>, Priority<0>, InvokeContext& invoke_context, Value&& value, Output&& output)
23+
{
24+
BuildField(TypeList<LocalType>(), invoke_context, output, std::forward<Value>(value));
25+
}
26+
27+
template <typename LocalType, typename Value, typename Output>
28+
void CustomBuildField(TypeList<LocalType&&>,
29+
Priority<0>,
30+
InvokeContext& invoke_context,
31+
Value&& value,
32+
Output&& output)
33+
{
34+
BuildField(TypeList<LocalType>(), invoke_context, output, std::forward<Value>(value));
35+
}
36+
} // namespace mp
37+
38+
#endif // MP_PROXY_TYPE_DECAY_H

test/mp/test/foo-types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <mp/proxy-types.h>
99
#include <mp/type-context.h>
10+
#include <mp/type-decay.h>
1011
#include <mp/type-interface.h>
1112
#include <mp/type-map.h>
1213
#include <mp/type-message.h>

0 commit comments

Comments
 (0)