28#if defined( DAW_JSON_CNTTP_JSON_NAME )
35 template<std::
size_t N>
37 static_assert( N > 0 );
38 char const m_data[N]{ };
40 template<std::size_t... Is>
41 DAW_ATTRIB_INLINE DAW_CONSTEVAL json_name(
42 daw::not_null<char const *> ptr, std::index_sequence<Is...> ) noexcept
43 : m_data{ ptr[Is]... } {}
45 DAW_ATTRIB_INLINE DAW_CONSTEVAL
46 json_name(
char const ( &ptr )[N] ) noexcept
47 : json_name( ptr, std::make_index_sequence<N>{ } ) {}
49 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr
50 operator daw::string_view( )
const noexcept {
51 return { m_data, N - 1 };
55 [[nodiscard]] DAW_ATTRIB_RET_NONNULL
56 DAW_ATTRIB_INLINE
constexpr char const *
57 begin( )
const noexcept {
62 [[nodiscard]] DAW_ATTRIB_RET_NONNULL
63 DAW_ATTRIB_INLINE
constexpr char const *
64 end( )
const noexcept {
65 return m_data +
static_cast<ptrdiff_t
>( size( ) );
68 [[nodiscard]]
static DAW_CONSTEVAL std::size_t size( ) {
72 [[nodiscard]]
static DAW_CONSTEVAL
bool empty( ) {
76 template<std::
size_t M>
77 [[nodiscard]]
constexpr bool
78 operator==( json_name<M>
const &rhs )
const noexcept {
82 for( std::size_t n = 0; n < N; ++n ) {
83 if( m_data[n] != rhs.m_data[n] ) {
90 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr bool
91 operator==( daw::string_view rhs )
const noexcept {
92 return daw::string_view( m_data, N - 1 ) == rhs;
95 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr bool
96 operator==( std::string_view rhs )
const noexcept {
97 return std::string_view( m_data, N - 1 ) == rhs;
100 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr
101 operator std::string_view( )
const noexcept {
102 return std::string_view( m_data, N - 1 );
105 template<
typename... Chars>
106 json_name( Chars... ) -> json_name<
sizeof...( Chars )>;
108 template<std::
size_t N>
109 json_name(
char const ( & )[N] ) -> json_name<N>;
111#define JSONNAMETYPE ::daw::json::json_name
116#define JSONNAMETYPE char const *
120 namespace json_details {
123 template<
typename... Ts>
124 DAW_CPP20_CONCEPT all_have_name_v = ( has_name_v<Ts> and ... );
127 DAW_CPP20_CONCEPT is_no_name_v = not has_name_v<T>;
129 template<
typename... Ts>
130 DAW_CPP20_CONCEPT are_no_name_v = ( is_no_name_v<Ts> and ... );