ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
T_ZTCharArray< std::basic_string< TChar >, TChar, typename std::enable_if< TT_IsChar< TChar >::value >::type > Struct Template Reference

Description:

template<typename TChar>
struct alib::characters::compatibility::std::T_ZTCharArray< std::basic_string< TChar >, TChar, typename std::enable_if< TT_IsChar< TChar >::value >::type >

Specialization of TMP struct T_ZTCharArray for type std::basic_string<TChar>:

  • Zero-terminated character string data is allowed to be implicitly accessed, because the type's buffer access method data() returns zero-terminated strings and is defined const.
  • The type may be created from character array data in an explicit fashion only, because it is a is a heavy-weight string type which will copy the data to an allocated buffer.
Note
In combination with classes CString and AString , explicit creation is suppressed using TMP struct T_SuppressAutoCast , because otherwise an ambiguity would occur due to their ability to implicitly cast to const char*, which implicitly constructs std::string in turn. This leads to the bad situation that an explicit construction like this:
      std::string stdString( cString );
uses the implicit cast to const char* and with that constructs the std::string. This is of-course very inefficient, as the length of the string has to be determined internally.

The most efficient way to create a std::string object from an object of type CString or AString is to use the explicit constructor:

      std::string stdString( String.Buffer(), String.Length() );
Template Parameters
TCharTemplate parameter providing the underlying character type. Restricted to types enabled by TMP helper struct TT_IsChar .

Definition at line 171 of file std_characters.hpp.

#include <std_characters.hpp>


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