|
BDE 4.39.x Production Release
|
Provide a compile-time check for types convertible to C-string.
Provide a compile-time check for types convertible to C-string.
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.
In this section we show the intended use of this component.
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 *:
Now, we instantiate the bslstl::IsConvertibleToCString template for various types and verify the results: