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

#include <posix.h>

Public Member Functions

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

Private Attributes

const Char * data_
 

Detailed Description

template<typename Char>
class basic_cstring_view< Char >

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 typedefs 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);

Definition at line 93 of file posix.h.

Constructor & Destructor Documentation

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 99 of file posix.h.

99 : data_(s) {}
const Char * data_
Definition: posix.h:95
static QCString * s
Definition: config.cpp:1042
template<typename Char >
basic_cstring_view< Char >::basic_cstring_view ( const std::basic_string< Char > &  s)
inline

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

Definition at line 106 of file posix.h.

106 : data_(s.c_str()) {}
const Char * data_
Definition: posix.h:95

Member Function Documentation

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

Returns the pointer to a C string.

Definition at line 109 of file posix.h.

109 { return data_; }
const Char * data_
Definition: posix.h:95

Member Data Documentation

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

Definition at line 95 of file posix.h.


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