Commit 5219f070 authored by Sarang Masti's avatar Sarang Masti Committed by Dave Watson

Allow conversion from StringPiece to StringPiece

Summary: Allow conversion from folly::StringPiece to folly::StringPiece

Test Plan: - fbconfig -r folly && fbmake runtests

Reviewed By: mpawlowski@fb.com

Subscribers: folly-diffs@

FB internal diff: D1752609

Signature: t1:1752609:1419037172:04846f658901306b53fb60c9eafbdf0f4d4d7005
parent 36194fe4
......@@ -820,14 +820,15 @@ template <class De, class Ts>
void toAppendDelimFit(const De&, const Ts&) {}
/**
* to<SomeString>(SomeString str) returns itself. As both std::string and
* folly::fbstring use Copy-on-Write, it's much more efficient by
* avoiding copying the underlying char array.
* to<SomeString>(SomeString str) or to<StringPiece>(StringPiece str) returns
* itself. As both std::string and folly::fbstring use Copy-on-Write, it's much
* more efficient by avoiding copying the underlying char array.
*/
template <class Tgt, class Src>
typename std::enable_if<
IsSomeString<Tgt>::value && std::is_same<Tgt, Src>::value,
Tgt>::type
(IsSomeString<Tgt>::value
|| std::is_same<Tgt, folly::StringPiece>::value)
&& std::is_same<Tgt, Src>::value, Tgt>::type
to(const Src & value) {
return value;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment