[PATCH] D32107: [libc++][test] LWG2857 test coverage for variant

2017-04-15 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF commandeered this revision.
EricWF edited reviewers, added: CaseyCarter; removed: EricWF.
EricWF added a comment.

LGTM, Thanks @CaseyCarter.

I committed these tests and the changes to libc++'s variant in r300403.

I'm hijacking this revision so I can close it.


https://reviews.llvm.org/D32107



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32107: [libc++][test] LWG2857 test coverage for variant

2017-04-14 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D32107#727751, @EricWF wrote:

> Give me a day to implement this in variant and then this should be ready to 
> land.


No rush; the patch isn't going anywhere ;)


https://reviews.llvm.org/D32107



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32107: [libc++][test] LWG2857 test coverage for variant

2017-04-14 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Give me a day to implement this in variant and then this should be ready to 
land.


https://reviews.llvm.org/D32107



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32107: [libc++][test] LWG2857 test coverage for variant

2017-04-14 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

As the saying goes, "works on my machine."

NOTE: libc++ variant does not yet implement LWG2857 and will not pass these 
tests; MSVC variant does.

Changes under `TEST_VARIANT_HAS_NO_REFERENCES` are dry-coded; I figure that's 
better than nothing.


https://reviews.llvm.org/D32107

Files:
  
test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp
  
test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp
  
test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp
  
test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp

Index: test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp
@@ -15,7 +15,7 @@
 // template  class variant;
 
 // template 
-// void emplace(initializer_list il,Args&&... args);
+//   T& emplace(initializer_list il,Args&&... args);
 
 #include 
 #include 
@@ -70,13 +70,19 @@
 void test_basic() {
   using V = std::variant;
   V v;
-  v.emplace({1, 2, 3});
+  auto& ref1 = v.emplace({1, 2, 3});
+  static_assert(std::is_same_v, "");
   assert(std::get(v).size == 3);
-  v.emplace({1, 2, 3, 4}, 42);
+  assert( == ::get(v));
+  auto& ref2 = v.emplace({1, 2, 3, 4}, 42);
+  static_assert(std::is_same_v, "");
   assert(std::get(v).size == 4);
   assert(std::get(v).value == 42);
-  v.emplace({1});
+  assert( == ::get(v));
+  auto& ref3 = v.emplace({1});
+  static_assert(std::is_same_v, "");
   assert(std::get(v).size == 1);
+  assert( == ::get(v));
 }
 
 int main() {
Index: test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp
@@ -14,7 +14,7 @@
 
 // template  class variant;
 
-// template  void emplace(Args&&... args);
+// template  T& emplace(Args&&... args);
 
 #include 
 #include 
@@ -86,24 +86,34 @@
   {
 using V = std::variant;
 V v(42);
-v.emplace();
+auto& ref1 = v.emplace();
+static_assert(std::is_same_v, "");
 assert(std::get<0>(v) == 0);
-v.emplace(42);
+assert( == ::get<0>(v));
+auto& ref2 = v.emplace(42);
+static_assert(std::is_same_v, "");
 assert(std::get<0>(v) == 42);
+assert( == ::get<0>(v));
   }
   {
 using V =
 std::variant;
 const int x = 100;
 V v(std::in_place_type, -1);
 // default emplace a value
-v.emplace();
+auto& ref1 = v.emplace();
+static_assert(std::is_same_v, "");
 assert(std::get<1>(v) == 0);
-v.emplace();
+assert( == ::get<1>(v));
+auto& ref2 = v.emplace();
+static_assert(std::is_same_v, "");
 assert(std::get<2>(v) == );
+assert( == ::get<2>(v));
 // emplace with multiple args
-v.emplace(3, 'a');
+auto& ref3 = v.emplace(3, 'a');
+static_assert(std::is_same_v, "");
 assert(std::get<4>(v) == "aaa");
+assert( == ::get<4>(v));
   }
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {
@@ -114,20 +124,30 @@
 int z = 43;
 V v(std::in_place_index<0>, -1);
 // default emplace a value
-v.emplace();
+auto& ref1 = v.emplace();
+static_assert(std::is_same_v, "");
 assert(std::get(v) == 0);
+assert( == ::get(v));
 // emplace a reference
-v.emplace(x);
+auto& ref2 = v.emplace(x);
+static_assert(std::is_same_v, "");
 assert(::get(v) == );
+assert( == ::get(v));
 // emplace an rvalue reference
-v.emplace(std::move(y));
+auto& ref3 = v.emplace(std::move(y));
+static_assert(std::is_same_v, "");
 assert(::get(v) == );
+assert( == ::get(v));
 // re-emplace a new reference over the active member
-v.emplace(std::move(z));
+auto& ref4 = v.emplace(std::move(z));
+static_assert(std::is_same_v, "");
 assert(::get(v) == );
+assert( == ::get(v));
 // emplace with multiple args
-v.emplace(3, 'a');
+auto& ref5 = v.emplace(3, 'a');
+static_assert(std::is_same_v, "");
 assert(std::get(v) == "aaa");
+assert( == ::get(v));
   }
 #endif
 }
Index: test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp