Public Member Functions | Private Attributes | List of all members
basic_cstring_view< Char > Class Template Reference

#include <os.h>

Public Member Functions

 basic_cstring_view (const Char *s)
 
 basic_cstring_view (const std::basic_string< Char > &s)
 
auto c_str () const -> const Char *
 

Private Attributes

const Char * data_
 

Detailed Description

template<typename Char>
class basic_cstring_view< Char >

\rst A reference to a null-terminated string. It can be constructed from a C string or std::string.

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

+------------—+--------------------------—+ | Type | Definition | +===============+=============================+ | cstring_view | basic_cstring_view<char> | +------------—+--------------------------—+ | wcstring_view | basic_cstring_view<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(cstring_view format_str, const Args & ... args);

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

Definition at line 104 of file os.h.

Constructor & Destructor Documentation

◆ basic_cstring_view() [1/2]

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

Constructs a string reference object from a C string.

Definition at line 110 of file os.h.

◆ basic_cstring_view() [2/2]

template<typename Char >
basic_cstring_view< Char >::basic_cstring_view ( const std::basic_string< Char > &  s)
inline

\rst Constructs a string reference from an std::string object. \endrst

Definition at line 117 of file os.h.

Member Function Documentation

◆ c_str()

template<typename Char >
auto basic_cstring_view< Char >::c_str ( ) const -> const Char*
inline

Returns the pointer to a C string.

Definition at line 120 of file os.h.

Member Data Documentation

◆ data_

template<typename Char >
const Char* basic_cstring_view< Char >::data_
private

Definition at line 106 of file os.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:28