bitz-server  2.0.3
Public Member Functions | Friends | List of all members
fmt::BasicStringRef< Char > Class Template Reference

#include <format.h>

Public Member Functions

 BasicStringRef (const Char *s, std::size_t size)
 
 BasicStringRef (const Char *s)
 
template<typename Allocator >
 BasicStringRef (const std::basic_string< Char, std::char_traits< Char >, Allocator > &s)
 
std::basic_string< Char > to_string () const
 
const Char * data () const
 
std::size_t size () const
 
int compare (BasicStringRef other) const
 

Friends

bool operator== (BasicStringRef lhs, BasicStringRef rhs)
 
bool operator!= (BasicStringRef lhs, BasicStringRef rhs)
 
bool operator< (BasicStringRef lhs, BasicStringRef rhs)
 
bool operator<= (BasicStringRef lhs, BasicStringRef rhs)
 
bool operator> (BasicStringRef lhs, BasicStringRef rhs)
 
bool operator>= (BasicStringRef lhs, BasicStringRef rhs)
 

Detailed Description

template<typename Char>
class fmt::BasicStringRef< Char >

A string reference. It can be constructed from a C string or std::basic_string.

You can use one of the following typedefs for common character types:

+---------—+----------------------—+ | Type | Definition | +============+=========================+ | StringRef | BasicStringRef<char> | +---------—+----------------------—+ | WStringRef | BasicStringRef<wchar_t> | +---------—+----------------------—+

This class is most useful as a parameter type to allow passing different types of strings to a function, for example::

template <typename... Args> std::string format(StringRef format_str, const Args & ... args);

format("{}", 42); format(std::string("{}"), 42);

Constructor & Destructor Documentation

◆ BasicStringRef() [1/3]

template<typename Char>
fmt::BasicStringRef< Char >::BasicStringRef ( const Char *  s,
std::size_t  size 
)
inline

Constructs a string reference object from a C string and a size.

◆ BasicStringRef() [2/3]

template<typename Char>
fmt::BasicStringRef< Char >::BasicStringRef ( const Char *  s)
inline

Constructs a string reference object from a C string computing the size with std::char_traits<Char>::length.

◆ BasicStringRef() [3/3]

template<typename Char>
template<typename Allocator >
fmt::BasicStringRef< Char >::BasicStringRef ( const std::basic_string< Char, std::char_traits< Char >, Allocator > &  s)
inline

Constructs a string reference from a std::basic_string object.

Member Function Documentation

◆ data()

template<typename Char>
const Char* fmt::BasicStringRef< Char >::data ( ) const
inline

Returns a pointer to the string data.

◆ size()

template<typename Char>
std::size_t fmt::BasicStringRef< Char >::size ( ) const
inline

Returns the string size.

◆ to_string()

template<typename Char>
std::basic_string<Char> fmt::BasicStringRef< Char >::to_string ( ) const
inline

Converts a string reference to an std::string object.