cppx-core
|
C_str for char const*
; Wide_c_str for wchar_t const*
; and Mutable_c_str and Mutable_wide_c_str as ditto mutable types.
More...
#include <cppx-core/language/types/type-makers.hpp>
Go to the source code of this file.
Namespaces | |
cppx | |
Typedefs | |
template<class Char > | |
using | cppx::C_str_ = P_< Const_< Char > > |
template<class Char > | |
using | cppx::Mutable_c_str_ = P_< Unconst_< Char > > |
using | cppx::C_str = C_str_< char > |
using | cppx::Wide_c_str = C_str_< wchar_t > |
using | cppx::Mutable_c_str = Mutable_c_str_< char > |
using | cppx::Mutable_wide_c_str = Mutable_c_str_< wchar_t > |
C_str for char const*
; Wide_c_str for wchar_t const*
; and Mutable_c_str and Mutable_wide_c_str as ditto mutable types.
The shortest names like C_str
stand for const
string data. The prefix Mutable_
, as in Mutable_c_str
, indicates mutable string data. This naming reflects an experience that handling const
string data is by far most common.
Using the type names avoids issues with non-reading direction placement of *
, and it supports prefix const
. For example, instead of
char const* const s = "Blah";
... you can write
const C_str s = "Blah";
Of course, for this particular example it would be silly to throw away the string length information, so one should better use std::string_view
and write
constexpr string_view s = "Blah";
Definition in file C_str_.hpp.