From 46bb1ed780a2ce03d856a98d4e2061d7f13b6f8c Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Tue, 28 Jul 2015 16:35:54 -0700 Subject: [PATCH] [folly] Enable support of applyTuple for const tuples Summary: This diff fixes the helper template ReturnValue to enable using of applyTuple with constant refs. Reviewed By: @ot, @ddrcoder Differential Revision: D2284733 --- folly/ApplyTuple.h | 6 +++--- folly/test/ApplyTupleTest.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/folly/ApplyTuple.h b/folly/ApplyTuple.h index 741429a4..a592704f 100644 --- a/folly/ApplyTuple.h +++ b/folly/ApplyTuple.h @@ -91,7 +91,7 @@ struct CallTuple { // The point of this meta function is to extract the contents of the // tuple as a parameter pack so we can pass it into std::result_of<>. -template struct ReturnValue {}; +template struct ReturnValue; template struct ReturnValue> { typedef typename std::result_of::type type; @@ -104,12 +104,12 @@ struct ReturnValue> { template typename detail::ReturnValue< typename std::decay::type, - typename std::remove_reference::type + typename std::decay::type >::type applyTuple(const Callable& c, Tuple&& t) { typedef typename detail::ReturnValue< typename std::decay::type, - typename std::remove_reference::type + typename std::decay::type >::type RetT; return detail::CallTuple::call(c, std::forward(t)); } diff --git a/folly/test/ApplyTupleTest.cpp b/folly/test/ApplyTupleTest.cpp index 195bb7b7..971f5b6d 100644 --- a/folly/test/ApplyTupleTest.cpp +++ b/folly/test/ApplyTupleTest.cpp @@ -86,7 +86,7 @@ struct GuardObj : GuardObjBase { : f_(std::move(f)) , args_(std::move(args)) {} - GuardObj(GuardObj&& g) + GuardObj(GuardObj&& g) noexcept : GuardObjBase(std::move(g)) , f_(std::move(g.f_)) , args_(std::move(g.args_)) @@ -163,4 +163,6 @@ TEST(ApplyTuple, Test) { Mover m; folly::applyTuple(move_only_func, std::forward_as_tuple(std::forward(Mover()))); + const auto tuple3 = std::make_tuple(1, 2, 3.0); + folly::applyTuple(func, tuple3); } -- 2.34.1