Bitcoin Core  31.0.0
P2P Digital Currency
type-chrono.h
Go to the documentation of this file.
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_CHRONO_H
6 #define MP_PROXY_TYPE_CHRONO_H
7 
8 #include <mp/util.h>
9 
10 #include <chrono>
11 
12 namespace mp {
15 template <class Rep, class Period, typename Value, typename Output>
16 void CustomBuildField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context, Value&& value,
17  Output&& output)
18 {
19  static_assert(std::numeric_limits<decltype(output.get())>::lowest() <= std::numeric_limits<Rep>::lowest(),
20  "capnp type does not have enough range to hold lowest std::chrono::duration value");
21  static_assert(std::numeric_limits<decltype(output.get())>::max() >= std::numeric_limits<Rep>::max(),
22  "capnp type does not have enough range to hold highest std::chrono::duration value");
23  output.set(value.count());
24 }
25 
26 template <class Rep, class Period, typename Input, typename ReadDest>
27 decltype(auto) CustomReadField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context,
28  Input&& input, ReadDest&& read_dest)
29 {
30  return read_dest.construct(input.get());
31 }
32 } // namespace mp
33 
34 #endif // MP_PROXY_TYPE_CHRONO_H
Function parameter type for prioritizing overloaded function calls that would otherwise be ambiguous...
Definition: util.h:108
Definition: common.h:29
Generic utility functions used by capnp code.
Definition: util.h:32
Functions to serialize / deserialize common bitcoin types.
Definition: common-types.h:57
decltype(auto) CustomReadField(TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) requires Unserializable< LocalType
Overload multiprocess library&#39;s CustomReadField hook to allow any object with an Unserialize method t...
Definition: common-types.h:100
void CustomBuildField(TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) requires Serializable< LocalType
Overload multiprocess library&#39;s CustomBuildField hook to allow any serializable object to be stored i...