Tweak basic_fbstring construction from std types
authorPhil Willoughby <philwill@fb.com>
Wed, 17 May 2017 11:05:52 +0000 (04:05 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 17 May 2017 11:24:42 +0000 (04:24 -0700)
commit6c244d162cd8f6e598202146c03b9bf13499d113
tree78cdfdb8e7b50a513bcd67f98b71bf1f0528bc91
parent1b546da9faec9c673bf637aeaca1bc604857cbc1
Tweak basic_fbstring construction from std types

Summary:
Previously we defined an assignment from std::string on all basic_fbstring
specialisations, but we don't actually want to do that because it's nonsense to
construct a basic_fbstring<char16_t> from an std::string. Equally it's not
nonsense to construct one of those from an std::u16string but the previous code
didn't allow it.

We now permit basic_fbstring<C, T, A1, S> to be constructed or assigned-to from
std::basic_string<C, T, A2>. The character type and traits must match but the
allocator is permitted to vary.

Background on my determination that the allocator type was unimportant and
could be disregarded: In part this is because C++17 made the same choice for
basic_string_view. Another factor was C++17's std::pmr::string (it's a
std::string with a different allocator) which I thought should be convertible
to fbstring in the same way as std::string.

Reviewed By: Gownta

Differential Revision: D5060569

fbshipit-source-id: f8984c528b76356240970c67916c58995d3f228d
folly/FBString.h