27#if defined( DAW_JSON_CNTTP_JSON_NAME )
34 template<std::
size_t N>
36 static_assert( N > 0 );
37 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]] DAW_ATTRIB_INLINE
constexpr std::size_t size( )
noexcept {
73 template<std::
size_t M>
74 [[nodiscard]]
constexpr bool
75 operator==( json_name<M>
const &rhs )
const noexcept {
79 for( std::size_t n = 0; n < N; ++n ) {
80 if( m_data[n] != rhs.m_data[n] ) {
87 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr bool
88 operator==( daw::string_view rhs )
const noexcept {
89 return daw::string_view( m_data, N - 1 ) == rhs;
92 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr bool
93 operator==( std::string_view rhs )
const noexcept {
94 return std::string_view( m_data, N - 1 ) == rhs;
97 [[nodiscard]] DAW_ATTRIB_INLINE
constexpr
98 operator std::string_view( )
const noexcept {
99 return std::string_view( m_data, N - 1 );
102 template<
typename... Chars>
103 json_name( Chars... ) -> json_name<
sizeof...( Chars )>;
105 template<std::
size_t N>
106 json_name(
char const ( & )[N] ) -> json_name<N>;
108#define JSONNAMETYPE ::daw::json::json_name
113#define JSONNAMETYPE char const *
117 namespace json_details {
120 template<
typename... Ts>
121 inline constexpr bool all_have_name_v = ( has_name_v<Ts> and ... );
124 inline constexpr bool is_no_name_v = not has_name_v<T>;
126 template<
typename... Ts>
127 inline constexpr bool are_no_name_v = ( is_no_name_v<Ts> and ... );