BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_isconvertibletocstring

Detailed Description

Provide a compile-time check for types convertible to C-string.

Outline

Purpose

Provide a compile-time check for types convertible to C-string.

Classes

See also
bslmf_isconvertible, bslstl_isconvertibletostringview

Description

This component provides a meta-function, bslstl::IsConvertibleToCString, that may be used to query (at compile-time) whether a type is convertible to a C-string (i.e., const CHAR_TYPE *).

bslstl::IsConvertibleToCString meets the requirements of the UnaryTypeTrait concept defined in the C++ standard [meta.rqmts] with a base characteristic of bsl::true_type if the (template parameter) TYPE is convertible to const CHAR_TYPE *, and a base characteristic of bsl::false_type otherwise.

Usage

In this section we show the intended use of this component.

Example 1: Determine If a Type Is Convertible to a C-String

Suppose that we want to determine whether various types are convertible to C-strings (null-terminated character arrays).

First, we create a type that is convertible to const char *:

struct MyCStringWrapper {
const char *d_str;
operator const char *() const { return d_str; }
};

Now, we instantiate the bslstl::IsConvertibleToCString template for various types and verify the results: