Disambiguate the various in_place overloads, following C++17
authorYedidya Feldblum <yfeldblum@fb.com>
Sun, 2 Jul 2017 17:22:27 +0000 (10:22 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 2 Jul 2017 17:40:21 +0000 (10:40 -0700)
commit10fb4bb82bcd795e1ce2bc5a342e07617116c797
treeb80e009b21bc51579ca44d6d41ce92dc45fa9ec3
parentedf661e64a593de14b6fa8b3686fc12b51a51ea0
Disambiguate the various in_place overloads, following C++17

Summary:
[Folly] Disambiguate the various `in_place` overloads, following C++17.

Forwarding `folly::in_place` is ambiguous because there are multiple overloads and we depend on deduction to choose the correct overload. For example:

```lang=c++
enum struct Err {};
Expected<Expected<int, Err>, Err> val(in_place, in_place, 3); // fails to compile
```

So we must disambiguate the three overloads: the default, the typed, and the indexed.

C++17 defines `std::in_place`, `std::in_place_type<typename>`, and `std::in_place_index<std::size_t>`. Let us mimic that exactly, so that it becomes trivial to swap out our implementations for the standard implementations once we jump to C++17.

Reviewed By: Orvid

Differential Revision: D5362339

fbshipit-source-id: d4012b01796390e74d8c14cdf68af70102608039
folly/ExceptionWrapper-inl.h
folly/ExceptionWrapper.h
folly/Traits.h