8#define MSGPACK_NO_BOOST
9#define MSGPACK_USE_STD_VARIANT_ADAPTOR
16template <msgpack_concepts::HasMsgPack T>
struct convert<T> {
17 msgpack::object
const&
operator()(msgpack::object
const& o, T& v)
const
20 "MSGPACK_FIELDS requires default-constructible types (used during unpacking)");
21 v.msgpack([&](
auto&... args) {
22 auto static_checker = [&](
auto&... value_args) {
24 "MSGPACK_FIELDS requires a constructor that can take the types listed in MSGPACK_FIELDS. "
25 "Type or arg count mismatch, or member initializer constructor not available.");
28 if constexpr (!
requires {
typename T::MSGPACK_NO_STATIC_CHECK; }) {
29 std::apply(static_checker,
drop_keys(std::tie(args...)));
31 msgpack::type::define_map<
decltype(args)...>{ args... }.msgpack_unpack(o);
38template <msgpack_concepts::HasMsgPack T>
struct pack<T> {
39 template <
typename Stream> packer<Stream>&
operator()(msgpack::packer<Stream>& o, T
const& v)
const
42 "MSGPACK_FIELDS requires default-constructible types (used during unpacking)");
43 const_cast<T&
>(v).
msgpack([&](
auto&... args) {
44 auto static_checker = [&](
auto&... value_args) {
46 "T requires a constructor that can take the fields listed in MSGPACK_FIELDS (T will be "
47 "in template parameters in the compiler stack trace)"
48 "Check the MSGPACK_FIELDS macro usage in T for incompleteness or wrong order. "
49 "Alternatively, a matching member initializer constructor might not be available for T "
50 "and should be defined.");
53 if constexpr (!
requires {
typename T::MSGPACK_NO_STATIC_CHECK; }) {
54 std::apply(static_checker,
drop_keys(std::tie(args...)));
56 msgpack::type::define_map<
decltype(args)...>{ args... }.msgpack_pack(o);
constexpr std::array< uint8_t, S > convert(const std::string_view &in)
auto drop_keys(std::tuple< Args... > &&tuple)
Drops every first value pairwise of a flat argument tuple, assuming that they are keys.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
msgpack::object const & operator()(msgpack::object const &o, T &v) const
packer< Stream > & operator()(msgpack::packer< Stream > &o, T const &v) const