refl-cpp
refl::util::const_string< N > Struct Template Reference

#include <refl.hpp>

Public Member Functions

constexpr const_string () noexcept
 
constexpr const_string (const const_string< N > &other) noexcept
 
constexpr const_string (const char(&data)[N+1]) noexcept
 
constexpr operator const char * () const noexcept
 
 operator std::string () const noexcept
 
constexpr const char * c_str () const noexcept
 
std::string str () const noexcept
 
template<size_t Pos, size_t Count = npos>
constexpr auto substr () const noexcept
 

Public Attributes

char data [N+1]
 

Static Public Attributes

static constexpr size_t npos = static_cast<size_t>(-1)
 
static constexpr size_t size = N
 

Detailed Description

template<size_t N>
struct refl::util::const_string< N >

Represents a compile-time string. Used in refl-cpp for representing names of reflected types and members. Supports constexpr concatenation and substring, and is explicitly-convertible to const char* and std::string. REFL_MAKE_CONST_STRING can be used to create an instance from a literal string.

@typeparam <N> The length of the string excluding the terminating '\0' character.

See also
refl::descriptor::base_member_descriptor::name

Constructor & Destructor Documentation

◆ const_string() [1/3]

template<size_t N>
constexpr refl::util::const_string< N >::const_string ( )
inlineconstexprnoexcept

Creates an empty const_string.

◆ const_string() [2/3]

template<size_t N>
constexpr refl::util::const_string< N >::const_string ( const const_string< N > &  other)
inlineconstexprnoexcept

Creates a copy of a const_string.

◆ const_string() [3/3]

template<size_t N>
constexpr refl::util::const_string< N >::const_string ( const char(&)  data[N+1])
inlineconstexprnoexcept

Creates a const_string by copying the contents of data.

Member Function Documentation

◆ c_str()

template<size_t N>
constexpr const char* refl::util::const_string< N >::c_str ( ) const
inlineconstexprnoexcept

Returns a pointer to the contained zero-terminated string.

◆ operator const char *()

template<size_t N>
constexpr refl::util::const_string< N >::operator const char * ( ) const
inlineexplicitconstexprnoexcept

Explicitly converts to const char*.

◆ operator std::string()

template<size_t N>
refl::util::const_string< N >::operator std::string ( ) const
inlineexplicitnoexcept

Explicitly converts to std::string.

◆ str()

template<size_t N>
std::string refl::util::const_string< N >::str ( ) const
inlinenoexcept

Returns the contained string as an std::string.

◆ substr()

template<size_t N>
template<size_t Pos, size_t Count = npos>
constexpr auto refl::util::const_string< N >::substr ( ) const
inlineconstexprnoexcept

A constexpr version of std::string::substr.

Member Data Documentation

◆ data

template<size_t N>
char refl::util::const_string< N >::data[N+1]

The statically-sized character buffer used for storing the string.

◆ npos

template<size_t N>
constexpr size_t refl::util::const_string< N >::npos = static_cast<size_t>(-1)
staticconstexpr

The largest positive value size_t can hold.

◆ size

template<size_t N>
constexpr size_t refl::util::const_string< N >::size = N
staticconstexpr

The length of the string excluding the terminating '\0' character.


The documentation for this struct was generated from the following file: