Add a StringPiece constructor for any string view type

Description

While ICU4C has had its own string view class icu::StringPiece for several years now, the since then finalized C++17 standard library provides std::string_view and Abseil provides the forward-compatible absl::string_view (for users of older standard library versions), and there are other implementations too.

It would be most convenient for users of ICU if they could use whatever string view implementation they prefer in their own code and have this implicitly converted to icu::StringPiece when calling ICU.

Using the C++ SFINAE (substitution failure is not an error) technique, it's possible to provide an icu::StringPiece constructor that accepts any string view type that might be available in the current compilation unit, without adding any additional dependencies or configuration flags to ICU.

Status

Assignee

Fredrik Roubert

Reporter

Fredrik Roubert

Labels

None

Reviewer

Markus Scherer

Time Needed

None

Start date

None

Components

Fix versions

Priority

minor
Configure