FBString: fix constructors so it compiles with newer Clang's
authorSteve O'Brien <steveo@fb.com>
Tue, 10 Nov 2015 14:28:14 +0000 (06:28 -0800)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Tue, 10 Nov 2015 15:20:24 +0000 (07:20 -0800)
commitc5ec113681e195a0802b0f7c32c6b0e5e6daad46
treeec3a71d9bf3fc3febe31b94509730ab308bcb4c7
parente56f93932aefa41711444fdcb72ba7dcc54fb836
FBString: fix constructors so it compiles with newer Clang's

Summary: Using Clang 3.7, this minimal test program:

  #include <folly/FBString.h>
  struct S { folly::basic_fbstring<char> x; };
  int main(int argc, char *argv[]) {
    S s {};
    return 0;
  }

... breaks with the following error output:

  FBStringTest.cpp:5:8: error: chosen constructor is explicit in copy-initialization
    S s {};
         ^
  ./folly/FBString.h:1009:12: note: constructor declared here
    explicit basic_fbstring(const A& = A()) noexcept {
             ^
  FBStringTest.cpp:3:40: note: in implicit initialization of field 'x' with omitted initializer
  struct S { folly::basic_fbstring<char> x; };

... because this `basic_fbstring` is used in a struct and the struct is being default-constructed.

This patch splits the (nevertheless-correct) one-default-arg constructor into two, to deconfuse clang and have it select the correct constructor to avoid this issue.

Reviewed By: matbd

Differential Revision: D2632953

fb-gh-sync-id: 2c75ae85732678c31543f5cccc73d58317982f07
folly/FBString.h
folly/test/FBStringTest.cpp