Index: base/tuple.h |
diff --git a/base/tuple.h b/base/tuple.h |
index 62344a1233916317b5ff96659fc5370daa5c4260..e82f2e5f06ad8860f722879b44bfef1e150c23f1 100644 |
--- a/base/tuple.h |
+++ b/base/tuple.h |
@@ -104,6 +104,20 @@ struct MakeIndexSequenceImpl<N, Ns...> |
#endif // defined(OS_WIN) && defined(_PREFAST_) |
+// std::get() in <=libstdc++-4.6 returns an lvalue-reference for |
+// rvalue-reference of a tuple, where an rvalue-reference is expected. |
+template <size_t I, typename... Ts> |
+typename std::tuple_element<I, std::tuple<Ts...>>::type&& get( |
+ std::tuple<Ts...>&& t) { |
+ using ElemType = typename std::tuple_element<I, std::tuple<Ts...>>::type; |
+ return std::forward<ElemType>(std::get<I>(t)); |
danakj
2016/06/14 18:54:07
Why forward instead of move?
Trying to compare to
tzik
2016/06/14 22:34:52
This is needed when the ElemType is a lvalue-refer
danakj
2016/06/17 22:55:12
Hm. But isn't the return type already hardcoded to
tzik
2016/06/21 08:46:33
I added a test case to reveal std::move doesn't wo
|
+} |
+ |
+template <size_t I, typename T> |
+auto get(T& t) -> decltype(std::get<I>(t)) { |
+ return std::get<I>(t); |
+} |
+ |
template <size_t N> |
using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type; |