From: Yedidya Feldblum Date: Sun, 2 Jul 2017 17:22:27 +0000 (-0700) Subject: Disambiguate the various in_place overloads, following C++17 X-Git-Tag: v2017.07.03.00~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=10fb4bb82bcd795e1ce2bc5a342e07617116c797;p=folly.git 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, 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`, and `std::in_place_index`. 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 --- diff --git a/folly/ExceptionWrapper-inl.h b/folly/ExceptionWrapper-inl.h index c1e83785..eca49ba6 100644 --- a/folly/ExceptionWrapper-inl.h +++ b/folly/ExceptionWrapper-inl.h @@ -287,7 +287,7 @@ inline exception_wrapper::exception_wrapper(OnHeapTag, in_place_type_t, As&& template inline exception_wrapper::exception_wrapper(InSituTag, in_place_type_t, As&&... as) - : buff_{in_place, std::forward(as)...}, + : buff_{in_place_type, std::forward(as)...}, vptr_(&InPlace::ops_) {} inline exception_wrapper::exception_wrapper(exception_wrapper&& that) noexcept @@ -347,7 +347,7 @@ template < inline exception_wrapper::exception_wrapper(Ex&& ex) : exception_wrapper{ PlacementOf{}, - in_place, + in_place_type, exception_wrapper_detail::dont_slice(std::forward(ex))} { } @@ -359,7 +359,7 @@ template < inline exception_wrapper::exception_wrapper(in_place_t, Ex&& ex) : exception_wrapper{ PlacementOf{}, - in_place, + in_place_type, exception_wrapper_detail::dont_slice(std::forward(ex))} { } @@ -371,7 +371,7 @@ template < inline exception_wrapper::exception_wrapper(in_place_type_t, As&&... as) : exception_wrapper{ PlacementOf{}, - in_place, + in_place_type, std::forward(as)...} { } diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index 3a2ff717..8016168e 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -604,7 +604,7 @@ constexpr exception_wrapper::VTable exception_wrapper::InPlace::ops_; */ template exception_wrapper make_exception_wrapper(As&&... as) { - return exception_wrapper{in_place, std::forward(as)...}; + return exception_wrapper{in_place_type, std::forward(as)...}; } /** diff --git a/folly/Traits.h b/folly/Traits.h index 01222add..de720a4e 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -636,13 +636,13 @@ inline traits_detail::InPlaceTag in_place(traits_detail::InPlaceTag = {}) { } template -inline traits_detail::InPlaceTypeTag in_place( +inline traits_detail::InPlaceTypeTag in_place_type( traits_detail::InPlaceTypeTag = {}) { return {}; } template -inline traits_detail::InPlaceIndexTag in_place( +inline traits_detail::InPlaceIndexTag in_place_index( traits_detail::InPlaceIndexTag = {}) { return {}; }