From: Alexander Shaposhnikov <alexshap@fb.com> Date: Tue, 28 Jul 2015 23:35:54 +0000 (-0700) Subject: [folly] Enable support of applyTuple for const tuples X-Git-Tag: v0.53.0~42 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=46bb1ed780a2ce03d856a98d4e2061d7f13b6f8c;p=folly.git [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 --- 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<class F, class Args> struct ReturnValue {}; +template<class F, class Args> struct ReturnValue; template<class F, class ...Args> struct ReturnValue<F,std::tuple<Args...>> { typedef typename std::result_of<F (Args...)>::type type; @@ -104,12 +104,12 @@ struct ReturnValue<F,std::tuple<Args...>> { template<class Callable, class Tuple> typename detail::ReturnValue< typename std::decay<Callable>::type, - typename std::remove_reference<Tuple>::type + typename std::decay<Tuple>::type >::type applyTuple(const Callable& c, Tuple&& t) { typedef typename detail::ReturnValue< typename std::decay<Callable>::type, - typename std::remove_reference<Tuple>::type + typename std::decay<Tuple>::type >::type RetT; return detail::CallTuple<RetT>::call(c, std::forward<Tuple>(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>(Mover()))); + const auto tuple3 = std::make_tuple(1, 2, 3.0); + folly::applyTuple(func, tuple3); }