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>
42 DAW_ATTRIB_INLINE DAW_CONSTEVAL
43 json_name(
char const *ptr, std::index_sequence<Is...> ) noexcept
44 : m_data{ ptr[Is]... } {}
46 DAW_ATTRIB_INLINE DAW_CONSTEVAL
47 json_name(
char const ( &ptr )[N] ) noexcept
48 : json_name( ptr, std::make_index_sequence<N>{ } ) {}
50 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr
51 operator daw::string_view( )
const noexcept {
52 return { m_data, N - 1 };
56 [[nodiscard]] DAW_ATTRIB_RET_NONNULL
57 DAW_ATTRIB_INLINE
constexpr char const *
58 begin( )
const noexcept {
63 [[nodiscard]] DAW_ATTRIB_RET_NONNULL
64 DAW_ATTRIB_INLINE
constexpr char const *
65 end( )
const noexcept {
66 return m_data +
static_cast<ptrdiff_t
>( size( ) );
69 [[nodiscard]]
static DAW_CONSTEVAL std::size_t size( ) {
73 [[nodiscard]]
static DAW_CONSTEVAL
bool empty( ) {
77 template<std::
size_t M>
78 [[nodiscard]]
constexpr bool
79 operator==( json_name<M>
const &rhs )
const noexcept {
83 for( std::size_t n = 0; n < N; ++n ) {
84 if( m_data[n] != rhs.m_data[n] ) {
91 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr bool
92 operator==( daw::string_view rhs )
const noexcept {
93 return daw::string_view( m_data, N - 1 ) == rhs;
96 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr bool
97 operator==( std::string_view rhs )
const noexcept {
98 return std::string_view( m_data, N - 1 ) == rhs;
101 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr
102 operator std::string_view( )
const noexcept {
103 return std::string_view( m_data, N - 1 );
106 template<
typename... Chars>
107 json_name( Chars... ) -> json_name<
sizeof...( Chars )>;
109 template<std::
size_t N>
110 json_name(
char const ( & )[N] ) -> json_name<N>;
112#define JSONNAMETYPE ::daw::json::json_name
117#define JSONNAMETYPE char const *
121 namespace json_details {
124 template<
typename... Ts>
125 DAW_CPP20_CONCEPT all_have_name_v = ( has_name_v<Ts> and ... );
128 DAW_CPP20_CONCEPT is_no_name_v = not has_name_v<T>;
130 template<
typename... Ts>
131 DAW_CPP20_CONCEPT are_no_name_v = ( is_no_name_v<Ts> and ... );