[PATCH] D27199: [libcxx] Make std::ignore constexpr

Anton Bikineev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 03:56:40 PST 2016


AntonBikineev created this revision.
AntonBikineev added reviewers: mclow.lists, EricWF.
AntonBikineev added a subscriber: cfe-commits.

This addresses DR 2773 <http://cplusplus.github.io/LWG/lwg-defects.html#2773>.

  // 20.5.2.4, tuple creation functions:
  constexpr unspecified ignore;
  }


https://reviews.llvm.org/D27199

Files:
  include/tuple
  test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
  www/cxx1z_status.html


Index: www/cxx1z_status.html
===================================================================
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -407,7 +407,7 @@
 	<tr><td><a href="http://wg21.link/LWG2767">2767</a></td><td>not_fn call_wrapper can form invalid types</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="http://wg21.link/LWG2769">2769</a></td><td>Redundant const in the return type of any_cast(const any&)</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="http://wg21.link/LWG2771">2771</a></td><td>Broken Effects of some basic_string::compare functions in terms of basic_string_view</td><td>Issaquah</td><td>Complete</td></tr>
-	<tr><td><a href="http://wg21.link/LWG2773">2773</a></td><td>Making std::ignore constexpr</td><td>Issaquah</td><td></td></tr>
+	<tr><td><a href="http://wg21.link/LWG2773">2773</a></td><td>Making std::ignore constexpr</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="http://wg21.link/LWG2777">2777</a></td><td>basic_string_view::copy should use char_traits::copy</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="http://wg21.link/LWG2778">2778</a></td><td>basic_string_view is missing constexpr</td><td>Issaquah</td><td></td></tr>
 
Index: test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
===================================================================
--- test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
@@ -22,6 +22,15 @@
 
 #include "test_macros.h"
 
+#if TEST_STD_VER > 14
+template <class T>
+constexpr auto check_ce_ignore(T ignore)
+{
+    ignore = 4;
+    return ignore;
+}
+#endif
+
 int main()
 {
     {
@@ -40,4 +49,9 @@
         static_assert ( std::get<1>(t) == 1.1, "" );
     }
 #endif
+#if TEST_STD_VER > 14
+    {
+        constexpr auto t = check_ce_ignore(std::ignore);
+    }
+#endif
 }
Index: include/tuple
===================================================================
--- include/tuple
+++ include/tuple
@@ -70,7 +70,7 @@
     void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
 };
 
-const unspecified ignore;
+constexpr unspecified ignore;
 
 template <class... T> tuple<V...>  make_tuple(T&&...); // constexpr in C++14
 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
@@ -1047,11 +1047,11 @@
 struct __ignore_t
 {
     template <class _Tp>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
         const __ignore_t& operator=(_Tp&&) const {return *this;}
 };
 
-namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
+namespace { _LIBCPP_CONSTEXPR_AFTER_CXX14 const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
 
 template <class _Tp>
 struct __make_tuple_return_impl


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27199.79534.patch
Type: text/x-patch
Size: 2876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161129/4d4f3508/attachment.bin>


More information about the cfe-commits mailing list