explicit return types in Partial to work around gcc bug
authorNathan Bronson <ngbronson@fb.com>
Tue, 16 Aug 2016 20:11:33 +0000 (13:11 -0700)
committerFacebook Github Bot 7 <facebook-github-bot-7-bot@fb.com>
Tue, 16 Aug 2016 20:23:27 +0000 (13:23 -0700)
Summary: Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70983

Reviewed By: mhx, spacedentist

Differential Revision: D3724410

fbshipit-source-id: 692b1c1f49211a4170900505339794f09cec2369

folly/Partial.h

index f19941fbf19f514d3a91372c626f2c6f38fc6e36..248a86a987a3f9be64bb52aa5e5eb2d4ba3a0af2 100644 (file)
@@ -32,8 +32,14 @@ class Partial {
       : f_(std::forward<Callable>(callable)),
         stored_args_(std::forward<Args>(args)...) {}
 
       : f_(std::forward<Callable>(callable)),
         stored_args_(std::forward<Args>(args)...) {}
 
+  // full auto doesn't work here due to
+  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70983 :(
+
   template <typename... CArgs>
   template <typename... CArgs>
-  auto operator()(CArgs&&... cargs) & {
+  auto operator()(CArgs&&... cargs) & -> decltype(applyTuple(
+      static_cast<F&>(f_),
+      static_cast<Tuple&>(stored_args_),
+      std::forward_as_tuple(std::forward<CArgs>(cargs)...))) {
     return applyTuple(
         static_cast<F&>(f_),
         static_cast<Tuple&>(stored_args_),
     return applyTuple(
         static_cast<F&>(f_),
         static_cast<Tuple&>(stored_args_),
@@ -41,7 +47,10 @@ class Partial {
   }
 
   template <typename... CArgs>
   }
 
   template <typename... CArgs>
-  auto operator()(CArgs&&... cargs) const& {
+  auto operator()(CArgs&&... cargs) const& -> decltype(applyTuple(
+      static_cast<F const&>(f_),
+      static_cast<Tuple const&>(stored_args_),
+      std::forward_as_tuple(std::forward<CArgs>(cargs)...))) {
     return applyTuple(
         static_cast<F const&>(f_),
         static_cast<Tuple const&>(stored_args_),
     return applyTuple(
         static_cast<F const&>(f_),
         static_cast<Tuple const&>(stored_args_),
@@ -49,7 +58,10 @@ class Partial {
   }
 
   template <typename... CArgs>
   }
 
   template <typename... CArgs>
-  auto operator()(CArgs&&... cargs) && {
+  auto operator()(CArgs&&... cargs) && -> decltype(applyTuple(
+      static_cast<F&&>(f_),
+      static_cast<Tuple&&>(stored_args_),
+      std::forward_as_tuple(std::forward<CArgs>(cargs)...))) {
     return applyTuple(
         static_cast<F&&>(f_),
         static_cast<Tuple&&>(stored_args_),
     return applyTuple(
         static_cast<F&&>(f_),
         static_cast<Tuple&&>(stored_args_),