X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FApplyTuple.h;h=a592704f080883a3a48433984e8fcb15e37d8d41;hb=49e4875c1e7d55df5913410539d299b7aa3c62bc;hp=5f535b9e054bfa16735db4aad5b898853b0b8ed1;hpb=9aa33f6ae63248816b9b5d7286f2d1740027d1d3;p=folly.git diff --git a/folly/ApplyTuple.h b/folly/ApplyTuple.h index 5f535b9e..a592704f 100644 --- a/folly/ApplyTuple.h +++ b/folly/ApplyTuple.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Facebook, Inc. + * Copyright 2015 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,13 +51,24 @@ struct DerefSize : std::tuple_size::type> {}; +template struct ExprDoUnpack { + enum { + value = sizeof...(Unpacked) < DerefSize::value + }; +}; + +template struct ExprIsUnpacked { + enum { + value = sizeof...(Unpacked) == DerefSize::value + }; +}; + // CallTuple recursively unpacks tuple arguments so we can forward // them into the function. template struct CallTuple { template - static typename std::enable_if< - (sizeof...(Unpacked) < DerefSize::value), + static typename std::enable_if::value, Ret >::type call(const F& f, Tuple&& t, Unpacked&&... unp) { typedef typename std::tuple_element< @@ -71,8 +82,7 @@ struct CallTuple { } template - static typename std::enable_if< - (sizeof...(Unpacked) == DerefSize::value), + static typename std::enable_if::value, Ret >::type call(const F& f, Tuple&& t, Unpacked&&... unp) { return makeCallable(f)(std::forward(unp)...); @@ -81,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; @@ -94,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)); }