Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: base/tuple_unittest.cc

Issue 2047013002: Add base::get to support rvalue-reference tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« base/tuple.h ('K') | « base/tuple.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/tuple.h" 5 #include "base/tuple.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 EXPECT_EQ(1, CopyLogger::TimesCopied); 107 EXPECT_EQ(1, CopyLogger::TimesCopied);
108 108
109 // Now they should be different, since the function call will make a copy. 109 // Now they should be different, since the function call will make a copy.
110 res = false; 110 res = false;
111 DispatchToFunction(&SomeLoggerMethCopy, tuple); 111 DispatchToFunction(&SomeLoggerMethCopy, tuple);
112 EXPECT_FALSE(res); 112 EXPECT_FALSE(res);
113 EXPECT_EQ(3, CopyLogger::TimesConstructed); 113 EXPECT_EQ(3, CopyLogger::TimesConstructed);
114 EXPECT_EQ(2, CopyLogger::TimesCopied); 114 EXPECT_EQ(2, CopyLogger::TimesCopied);
115 } 115 }
116 116
117 TEST(TupleTest, Get) {
118 int i = 1;
119 int j = 2;
120 std::tuple<int, int&, int&&> t(3, i, std::move(j));
121 EXPECT_TRUE((std::is_same<int&, decltype(base::get<0>(t))>::value));
122 EXPECT_TRUE((std::is_same<int&, decltype(base::get<1>(t))>::value));
123 EXPECT_TRUE((std::is_same<int&, decltype(base::get<2>(t))>::value));
124
125 EXPECT_TRUE((std::is_same<int&&,
126 decltype(base::get<0>(std::move(t)))>::value));
127 EXPECT_TRUE((std::is_same<int&,
128 decltype(base::get<1>(std::move(t)))>::value));
129 EXPECT_TRUE((std::is_same<int&&,
130 decltype(base::get<2>(std::move(t)))>::value));
131 }
132
117 } // namespace base 133 } // namespace base
OLDNEW
« base/tuple.h ('K') | « base/tuple.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698