11#include "daw/daw_tuple_forward.h"
14#include <daw/daw_attributes.h>
15#include <daw/daw_consteval.h>
17#include <boost/pfr.hpp>
18#include <daw/stdinc/tuple_traits.h>
26 requires( std::is_aggregate_v<T> and std::is_class_v<T> and
27 not std::is_empty_v<T> )
30 namespace pfr_details {
31 template<
typename T, std::
size_t Idx>
32 DAW_CONSTEVAL
auto get_member_name( ) {
33 DAW_CPP23_STATIC_LOCAL
constexpr auto name =
34 boost::pfr::get_name<Idx, T>( );
35 static_assert( not name.empty( ) );
36 return json_name<name.size( ) + 1>(
37 name.data( ), std::make_index_sequence<name.size( ) + 1>{ } );
40 template<
typename,
typename>
41 struct make_data_contract;
43 template<
typename T, std::size_t... Is>
44 struct make_data_contract<T,
std::index_sequence<Is...>> {
46 using member_types = DAW_TYPEOF(
47 boost::pfr::structure_to_tuple( std::declval<T const &>( ) ) );
52 std::tuple_element_t<Is, member_types>>...>;
54 DAW_ATTRIB_INLINE
static constexpr auto to_json_data( T
const &value ) {
55 return boost::pfr::structure_tie( value );
61 requires use_boost_pfr<T>
63 : pfr_details::make_data_contract<
64 T, std::make_index_sequence<boost::pfr::tuple_size_v<T>>> {};
Customization point traits.
constexpr bool use_boost_pfr
Enable Boost PFR mappings for a type.
Mapping class for JSON data structures to C++. It must be specialized in order to parse to a user cla...