Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

The MPL Reference Manual: c_str
Front Page / Metafunctions / String Operations / c_str

c_str

Synopsis

template<
      typename Sequence
    >
struct c_str
{
    typedef unspecified type;
    static char const value[];
};

Description

c_str converts the Forward Sequence of Integral Constants Sequence into a null-terminated byte string containing an equivalent sequence.

Parameters

Parameter Requirement Description
Sequence Forward Sequence of Integral Constants A sequence to be converted into a null-terminated byte string.

Expression semantics

For any Forward Sequence of Integral Constants s,

c_str::value;
Return type:

A null-terminated byte string.

Precondition:

size::value <= BOOST_MPL_STRING_MAX_LENGTH.

Semantics:

Equivalent to

char const value[] = {
    at::type::value
  , ...
  , atsize::value-1>::type::value
  , '\0'
};

Complexity

Sequence archetype Complexity
Forward Sequence Linear.

Example

typedef vector_c hello;
assert( 0 == std::strcmp( c_str::value, "hello" ) );