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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Determine if a Type Should be Treated as a String (Qi and Karma)

is_string

The is_string customization point is a template meta-function. It is used by Qi String Literals (lit(str)), Qi Character Literals (lit(c)), Karma String Literals (lit(str)), Karma Character Literals (lit(c)) and other Spirit components. It determines whether a supplied type can be treated as a string.

Module Headers
#include <boost/spirit/home/support/string_traits.hpp>

Also, see Include Structure.

[Note] Note

This header file does not need to be included directly by any user program as it is normally included by other Spirit header files relying on its content.

Namespace

Name

boost::spirit::traits

Synopsis
template <typename T>
struct is_string
{
    <unspecified>;
};
Template parameters

Parameter

Description

Default

T

The type, T which needs to be tested as a string

none

Notation

T

An arbitrary type.

N

An arbitrary integral constant.

Char

A character type.

Traits

A character traits type.

Allocator

A standard allocator type.

Expression Semantics

Expression

Semantics

is_string<T>::type

Result of the metafunction that evalutes to mpl::true_ if a given type, T, is to be treated as a string and mpl::false_ otherwise. Generally, any implementation of is_string needs to behave as if if was a MPL Boolean Constant.

Predefined Specializations

Type

Semantics

T

Returns mpl::false_.

T const

Returns is_string<T>.

char const*

Returns mpl::true_.

wchar_t const*

Returns mpl::true_.

char*

Returns mpl::true_.

wchar_t*

Returns mpl::true_.

char[N]

Returns mpl::true_.

wchar_t[N]

Returns mpl::true_.

char const[N]

Returns mpl::true_.

wchar_t const[N]

Returns mpl::true_.

char(&)[N]

Returns mpl::true_.

wchar_t(&)[N]

Returns mpl::true_.

char const(&)[N]

Returns mpl::true_.

wchar_t const(&)[N]

Returns mpl::true_.

std::basic_string<Char, Traits, Allocator>

Returns mpl::true_.

When to implement

This customization point needs to be implemented to use user-defined string classes that do not correspond to std::string syntax and semantics.

Related Attribute Customization Points

If this customization point is implemented, the following other customization points need to be implemented as well.

Name

When to implement

traits::is_char

For string types whose underlying character type is not char or wchar_t, is_char must be implemented.

traits::char_type_of

Whenever is_string is implemented.

traits::extract_c_string

Whenever is_string is implemented.


PrevUpHomeNext