Lines Matching refs:std
33 TestType(T&& value) : value_(std::move(value)) {} in TestType()
41 T&& take() { return std::move(value_); } in take()
53 InstrumentType(T&& value) : value_(std::move(value)) { constructor_count_++; } in InstrumentType()
57 InstrumentType(InstrumentType&& other) : value_(std::move(other.value_)) { in InstrumentType()
77 value_ = std::move(other.value_); in operator =()
92 static std::size_t constructor_count() { return constructor_count_; } in constructor_count()
93 static std::size_t destructor_count() { return destructor_count_; } in destructor_count()
94 static std::size_t move_assignment_count() { return move_assignment_count_; } in move_assignment_count()
95 static std::size_t copy_assignment_count() { return copy_assignment_count_; } in copy_assignment_count()
98 T&& take() { return std::move(value_); } in take()
110 static std::size_t constructor_count_;
111 static std::size_t destructor_count_;
112 static std::size_t move_assignment_count_;
113 static std::size_t copy_assignment_count_;
117 std::size_t InstrumentType<T>::constructor_count_ = 0;
119 std::size_t InstrumentType<T>::destructor_count_ = 0;
121 std::size_t InstrumentType<T>::move_assignment_count_ = 0;
123 std::size_t InstrumentType<T>::copy_assignment_count_ = 0;
144 EXPECT_EQ(10, std::get<int>(v)); in TEST()
154 EXPECT_EQ(false, std::get<bool>(v)); in TEST()
164 EXPECT_FLOAT_EQ(1.0f, std::get<float>(v)); in TEST()
183 EXPECT_FLOAT_EQ(1.1, std::get<float>(v)); in TEST()
187 Variant<int, std::string> v; in TEST()
190 ASSERT_FALSE(v.is<std::string>()); in TEST()
194 Variant<int, std::string> v; in TEST()
198 ASSERT_FALSE(v.is<std::string>()); in TEST()
199 EXPECT_EQ(20, std::get<int>(v)); in TEST()
203 Variant<int, std::string> v; in TEST()
204 v = std::string("test"); in TEST()
207 ASSERT_TRUE(v.is<std::string>()); in TEST()
208 EXPECT_EQ("test", std::get<std::string>(v)); in TEST()
212 Variant<int, std::string> v; in TEST()
216 ASSERT_TRUE(v.is<std::string>()); in TEST()
217 EXPECT_EQ("test", std::get<std::string>(v)); in TEST()
222 Variant<std::string> v2; in TEST()
227 ASSERT_TRUE(v2.is<std::string>()); in TEST()
228 EXPECT_EQ("test", std::get<std::string>(v2)); in TEST()
262 EXPECT_EQ(&b, std::get<char*>(v)); in TEST()
263 EXPECT_EQ(b, *std::get<char*>(v)); in TEST()
267 EXPECT_EQ(&a, std::get<int*>(v)); in TEST()
268 EXPECT_EQ(a, *std::get<int*>(v)); in TEST()
272 using IntRef = std::reference_wrapper<int>; in TEST()
278 EXPECT_EQ(a, std::get<IntRef>(v)); in TEST()
281 EXPECT_EQ(a, std::get<IntRef>(v)); in TEST()
287 Variant<std::string> v; in TEST()
288 std::string s = "test"; in TEST()
289 v = std::move(s); in TEST()
292 ASSERT_TRUE(v.is<std::string>()); in TEST()
293 EXPECT_EQ("test", std::get<std::string>(v)); in TEST()
297 Variant<std::string> v("test"); in TEST()
298 std::string s = "fizz"; in TEST()
299 s = std::move(std::get<std::string>(v)); in TEST()
301 ASSERT_TRUE(v.is<std::string>()); in TEST()
302 EXPECT_TRUE(std::get<std::string>(v).empty()); in TEST()
307 Variant<std::string> a("test"); in TEST()
308 Variant<std::string> b; in TEST()
310 b = std::move(a); in TEST()
311 ASSERT_TRUE(a.is<std::string>()); in TEST()
312 ASSERT_TRUE(b.is<std::string>()); in TEST()
313 EXPECT_TRUE(std::get<std::string>(a).empty()); in TEST()
314 EXPECT_EQ("test", std::get<std::string>(b)); in TEST()
318 Variant<std::string> a("test"); in TEST()
319 Variant<std::string> b("fizz"); in TEST()
321 b = std::move(a); in TEST()
322 ASSERT_TRUE(a.is<std::string>()); in TEST()
323 ASSERT_TRUE(b.is<std::string>()); in TEST()
324 EXPECT_TRUE(std::get<std::string>(a).empty()); in TEST()
325 EXPECT_EQ("test", std::get<std::string>(b)); in TEST()
329 Variant<int, std::string> a("test"); in TEST()
330 Variant<int, std::string> b(10); in TEST()
332 b = std::move(a); in TEST()
333 ASSERT_TRUE(a.is<std::string>()); in TEST()
334 ASSERT_TRUE(b.is<std::string>()); in TEST()
335 EXPECT_TRUE(std::get<std::string>(a).empty()); in TEST()
336 EXPECT_EQ("test", std::get<std::string>(b)); in TEST()
340 Variant<int, std::string> a(10); in TEST()
341 Variant<int, std::string> b("test"); in TEST()
343 b = std::move(a); in TEST()
346 EXPECT_EQ(10, std::get<int>(a)); in TEST()
347 EXPECT_EQ(10, std::get<int>(b)); in TEST()
368 Variant<float, std::string> v(10.); in TEST()
376 EXPECT_EQ(1, std::get<int>(v)); in TEST()
383 EXPECT_EQ(1, std::get<int>(v)); in TEST()
390 EXPECT_EQ(true, std::get<bool>(v)); in TEST()
397 EXPECT_EQ(true, std::get<bool>(v)); in TEST()
402 Variant<std::string> s(c); in TEST()
403 ASSERT_TRUE(s.is<std::string>()); in TEST()
404 EXPECT_EQ("test", std::get<std::string>(s)); in TEST()
415 using IntRef = std::reference_wrapper<int>; in TEST()
421 EXPECT_EQ(a, std::get<IntRef>(v)); in TEST()
425 EXPECT_EQ(a, std::get<IntRef>(v)); in TEST()
619 std::unique_ptr<int> pointer = std::make_unique<int>(10); in TEST()
620 Variant<std::unique_ptr<int>> v(std::move(pointer)); in TEST()
621 ASSERT_TRUE(v.is<std::unique_ptr<int>>()); in TEST()
622 EXPECT_TRUE(std::get<std::unique_ptr<int>>(v) != nullptr); in TEST()
627 Variant<std::unique_ptr<int>> a(std::make_unique<int>(10)); in TEST()
628 Variant<std::unique_ptr<int>> b(std::move(a)); in TEST()
630 ASSERT_TRUE(a.is<std::unique_ptr<int>>()); in TEST()
631 ASSERT_TRUE(b.is<std::unique_ptr<int>>()); in TEST()
632 EXPECT_TRUE(std::get<std::unique_ptr<int>>(a) == nullptr); in TEST()
633 EXPECT_TRUE(std::get<std::unique_ptr<int>>(b) != nullptr); in TEST()
688 Variant<std::string> v("test"); in TEST()
689 ASSERT_TRUE(v.is<std::string>()); in TEST()
690 EXPECT_FALSE(std::get<std::string>(v).empty()); in TEST()
693 std::remove_reference_t<decltype(value)> empty; in TEST()
694 std::swap(empty, value); in TEST()
696 ASSERT_TRUE(v.is<std::string>()); in TEST()
697 EXPECT_TRUE(std::get<std::string>(v).empty()); in TEST()
729 EXPECT_EQ(10, std::get<int>(v)); in TEST()
733 EXPECT_EQ(true, std::get<bool>(v)); in TEST()
737 EXPECT_FLOAT_EQ(2.0f, std::get<float>(v)); in TEST()
750 Variant<std::string> v; in TEST()
753 ASSERT_TRUE(v.is<std::string>()); in TEST()
754 EXPECT_TRUE(std::get<std::string>(v).empty()); in TEST()
758 Variant<std::string> v; in TEST()
761 ASSERT_TRUE(v.is<std::string>()); in TEST()
762 EXPECT_EQ("test", std::get<std::string>(v)); in TEST()
766 Variant<std::string> v("foo"); in TEST()
769 ASSERT_TRUE(v.is<std::string>()); in TEST()
770 EXPECT_EQ("foo", std::get<std::string>(v)); in TEST()
776 Variant<std::string> a; in TEST()
777 Variant<std::string> b; in TEST()
779 std::swap(a, b); in TEST()
785 Variant<std::string> a("1"); in TEST()
786 Variant<std::string> b; in TEST()
788 std::swap(a, b); in TEST()
791 ASSERT_TRUE(b.is<std::string>()); in TEST()
792 EXPECT_EQ("1", std::get<std::string>(b)); in TEST()
796 Variant<std::string> a; in TEST()
797 Variant<std::string> b("1"); in TEST()
799 std::swap(a, b); in TEST()
802 ASSERT_TRUE(a.is<std::string>()); in TEST()
803 EXPECT_EQ("1", std::get<std::string>(a)); in TEST()
807 Variant<std::string> a("1"); in TEST()
808 Variant<std::string> b("2"); in TEST()
810 std::swap(a, b); in TEST()
811 ASSERT_TRUE(a.is<std::string>()); in TEST()
812 ASSERT_TRUE(b.is<std::string>()); in TEST()
813 EXPECT_EQ("2", std::get<std::string>(a)); in TEST()
814 EXPECT_EQ("1", std::get<std::string>(b)); in TEST()
818 Variant<int, std::string> a(10); in TEST()
819 Variant<int, std::string> b("1"); in TEST()
821 std::swap(a, b); in TEST()
822 ASSERT_TRUE(a.is<std::string>()); in TEST()
824 EXPECT_EQ("1", std::get<std::string>(a)); in TEST()
825 EXPECT_EQ(10, std::get<int>(b)); in TEST()
829 Variant<int, std::string> a("1"); in TEST()
830 Variant<int, std::string> b(10); in TEST()
832 std::swap(a, b); in TEST()
834 ASSERT_TRUE(b.is<std::string>()); in TEST()
835 EXPECT_EQ(10, std::get<int>(a)); in TEST()
836 EXPECT_EQ("1", std::get<std::string>(b)); in TEST()
844 EXPECT_EQ(nullptr, &std::get<int>(v)); in TEST()
845 EXPECT_EQ(nullptr, &std::get<bool>(v)); in TEST()
846 EXPECT_EQ(nullptr, &std::get<float>(v)); in TEST()
847 EXPECT_EQ(nullptr, &std::get<0>(v)); in TEST()
848 EXPECT_EQ(nullptr, &std::get<1>(v)); in TEST()
849 EXPECT_EQ(nullptr, &std::get<2>(v)); in TEST()
850 EXPECT_EQ(nullptr, &std::get<3>(v)); in TEST()
858 EXPECT_EQ(9, std::get<int>(v)); in TEST()
859 EXPECT_EQ(9, std::get<0>(v)); in TEST()
861 std::get<int>(v) = 10; in TEST()
862 EXPECT_EQ(10, std::get<int>(v)); in TEST()
863 EXPECT_EQ(10, std::get<0>(v)); in TEST()
865 std::get<0>(v) = 11; in TEST()
866 EXPECT_EQ(11, std::get<int>(v)); in TEST()
867 EXPECT_EQ(11, std::get<0>(v)); in TEST()
869 std::get<3>(v) = 12; in TEST()
870 EXPECT_EQ(12, std::get<int>(v)); in TEST()
871 EXPECT_EQ(12, std::get<3>(v)); in TEST()
879 EXPECT_EQ(false, std::get<bool>(v)); in TEST()
880 EXPECT_EQ(false, std::get<1>(v)); in TEST()
882 std::get<bool>(v) = true; in TEST()
883 EXPECT_EQ(true, std::get<bool>(v)); in TEST()
884 EXPECT_EQ(true, std::get<1>(v)); in TEST()
886 std::get<bool>(v) = false; in TEST()
887 EXPECT_EQ(false, std::get<bool>(v)); in TEST()
888 EXPECT_EQ(false, std::get<1>(v)); in TEST()
890 std::get<1>(v) = true; in TEST()
891 EXPECT_EQ(true, std::get<bool>(v)); in TEST()
892 EXPECT_EQ(true, std::get<1>(v)); in TEST()
894 std::get<1>(v) = false; in TEST()
895 EXPECT_EQ(false, std::get<bool>(v)); in TEST()
896 EXPECT_EQ(false, std::get<1>(v)); in TEST()
905 EXPECT_FLOAT_EQ(1.0, std::get<float>(v)); in TEST()
906 EXPECT_FLOAT_EQ(1.0, std::get<2>(v)); in TEST()
908 std::get<float>(v) = 1.1; in TEST()
909 EXPECT_FLOAT_EQ(1.1, std::get<float>(v)); in TEST()
910 EXPECT_FLOAT_EQ(1.1, std::get<2>(v)); in TEST()
912 std::get<float>(v) = -3.0; in TEST()
913 EXPECT_FLOAT_EQ(-3.0, std::get<float>(v)); in TEST()
914 EXPECT_FLOAT_EQ(-3.0, std::get<2>(v)); in TEST()
916 std::get<2>(v) = 1.1; in TEST()
917 EXPECT_FLOAT_EQ(1.1, std::get<float>(v)); in TEST()
918 EXPECT_FLOAT_EQ(1.1, std::get<2>(v)); in TEST()
920 std::get<2>(v) = -3.0; in TEST()
921 EXPECT_FLOAT_EQ(-3.0, std::get<float>(v)); in TEST()
922 EXPECT_FLOAT_EQ(-3.0, std::get<2>(v)); in TEST()
926 Variant<std::unique_ptr<int>> v(std::make_unique<int>(10)); in TEST()
927 std::unique_ptr<int> pointer = std::move(std::get<std::unique_ptr<int>>(v)); in TEST()
930 EXPECT_TRUE(std::get<std::unique_ptr<int>>(v) == nullptr); in TEST()
934 Variant<std::string> v("test"); in TEST()
935 std::string s = std::get<std::string>(std::move(v)); in TEST()
982 Variant<std::unique_ptr<int>, int> v(std::make_unique<int>(10)); in TEST()
983 ASSERT_TRUE(v.is<std::unique_ptr<int>>()); in TEST()
984 const int* original_v = std::get<std::unique_ptr<int>>(v).get(); in TEST()
986 std::unique_ptr<int> u(std::make_unique<int>(20)); in TEST()
988 EXPECT_TRUE(IfAnyOf<std::unique_ptr<int>>::Take(&v, &u)); in TEST()
989 ASSERT_TRUE(v.is<std::unique_ptr<int>>()); in TEST()
990 EXPECT_TRUE(std::get<std::unique_ptr<int>>(v) == nullptr); in TEST()
995 Variant<std::unique_ptr<DerivedType>, int> v( in TEST()
996 std::make_unique<DerivedType>(10)); in TEST()
997 ASSERT_TRUE(v.is<std::unique_ptr<DerivedType>>()); in TEST()
999 std::get<std::unique_ptr<DerivedType>>(v).get(); in TEST()
1001 std::unique_ptr<BaseType> u(std::make_unique<BaseType>(20)); in TEST()
1003 EXPECT_TRUE(IfAnyOf<std::unique_ptr<DerivedType>>::Take(&v, &u)); in TEST()
1004 ASSERT_TRUE(v.is<std::unique_ptr<DerivedType>>()); in TEST()
1005 EXPECT_TRUE(std::get<std::unique_ptr<DerivedType>>(v) == nullptr); in TEST()
1010 Variant<std::unique_ptr<int>, int> v(std::make_unique<int>(10)); in TEST()
1011 ASSERT_TRUE(v.is<std::unique_ptr<int>>()); in TEST()
1012 const int* original_v = std::get<std::unique_ptr<int>>(v).get(); in TEST()
1014 std::unique_ptr<int> u(std::make_unique<int>(20)); in TEST()
1016 EXPECT_TRUE(IfAnyOf<std::unique_ptr<int>>::Call( in TEST()
1017 &v, [&u](auto&& value) { u = std::move(value); })); in TEST()
1018 ASSERT_TRUE(v.is<std::unique_ptr<int>>()); in TEST()
1019 EXPECT_TRUE(std::get<std::unique_ptr<int>>(v) == nullptr); in TEST()
1033 Variant<std::string, int> v("foo"); in TEST()
1034 ASSERT_TRUE(v.is<std::string>()); in TEST()
1036 std::string s = "bar"; in TEST()
1037 EXPECT_TRUE(IfAnyOf<std::string>::Swap(&v, &s)); in TEST()
1038 ASSERT_TRUE(v.is<std::string>()); in TEST()
1039 EXPECT_EQ("bar", std::get<std::string>(v)); in TEST()
1044 Variant<std::string, const char*> v(static_cast<const char*>("foo")); in TEST()
1047 std::string s = "bar"; in TEST()
1048 EXPECT_TRUE((IfAnyOf<std::string, const char*>::Take(&v, &s))); in TEST()
1050 EXPECT_EQ("foo", std::get<const char*>(v)); in TEST()
1053 v = std::string("bar"); in TEST()
1054 ASSERT_TRUE(v.is<std::string>()); in TEST()
1056 EXPECT_TRUE((IfAnyOf<std::string, const char*>::Take(&v, &s))); in TEST()
1057 ASSERT_TRUE(v.is<std::string>()); in TEST()
1062 Variant<std::string, const char*> v; in TEST()
1065 std::string s = "bar"; in TEST()
1066 EXPECT_FALSE((IfAnyOf<std::string, const char*>::Take(&v, &s))); in TEST()
1071 Variant<std::string, const char*> v(static_cast<const char*>("test")); in TEST()
1074 std::string s; in TEST()
1084 EXPECT_EQ(10, std::get<const int>(v)); in TEST()
1088 Variant<const std::string> v("test"); in TEST()
1089 ASSERT_TRUE(v.is<const std::string>()); in TEST()
1090 EXPECT_EQ("test", std::get<const std::string>(v)); in TEST()
1094 Variant<volatile int, std::string> v(10); in TEST()
1096 EXPECT_EQ(10, std::get<volatile int>(v)); in TEST()
1129 EXPECT_FALSE((detail::IsConstructible<TwoArgs, int, std::string>::value)); in TEST()