This component‐private utility struct provides a namespace for the flatten overload set intended to be used in concert with an overload set consisting of a function template with a deduced argument and an non‐template overload accepting a const char *. The actual implementation of the functionality would be in the const char * overload whereas the purpose of the function template is to invoke the const char * overload with a null‐terminated string.

Synopsis

Declared in <bdls_filesystemutil.h>

struct FilesystemUtil_CStringUtil;

Description

The function template achieves null‐termination by recursively calling the function and supplying it with the result of flatten invoked on the deduced argument. This flatten invocation will call c_str() on various supported string types, will produce a temporary bsl::string for possibly non‐null‐terminated bsl::string_view or bslstl::StringRef, and will result in a BSLMF_ASSERT for any unsupported type. Calling the function with the temporary bsl::string produced from bsl::string_view or bslstl::StringRef will result in a second invocation of flatten, this time producing const char *, and finally calling the function with a null‐terminated string.

Note that the bslstl::StringRef overload for flatten is provided for backwards compatibility. Without it, the bsl::string and std::string overloads would be ambiguous. In new code, it is preferable to not provide bslstl::StringRef overload in a similar facility and require the clients to explicitly state the string type in their code, making a potential allocation obvious. The same considerations apply to bsl::string_view.

Static Member Functions

Name

Description

flatten

flatten overloads

Created with MrDocs