Implement LWG 2393. Check for LValue-callability.
authorEric Fiselier <eric@efcs.ca>
Sun, 24 Jul 2016 04:16:40 +0000 (04:16 +0000)
committerEric Fiselier <eric@efcs.ca>
Sun, 24 Jul 2016 04:16:40 +0000 (04:16 +0000)
llvm-svn: 276546

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
libcxx/www/cxx1z_status.html

index 82a6f6c..fd296a7 100644 (file)
@@ -16,6 +16,7 @@
 #include <functional>
 #include <cassert>
 
+#include "test_macros.h"
 #include "count_new.hpp"
 
 class A
@@ -49,6 +50,17 @@ int A::count = 0;
 
 int g(int) {return 0;}
 
+#if TEST_STD_VER >= 11
+struct RValueCallable {
+    template <class ...Args>
+    void operator()(Args&&...) && {}
+};
+struct LValueCallable {
+    template <class ...Args>
+    void operator()(Args&&...) & {}
+};
+#endif
+
 int main()
 {
     assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -91,4 +103,13 @@ int main()
         std::function <void()> f(static_cast<void (*)()>(0));
         assert(!f);
     }
+#if TEST_STD_VER >= 11
+    {
+        using Fn = std::function<void(int, int, int)>;
+        static_assert(std::is_constructible<Fn, LValueCallable&>::value, "");
+        static_assert(std::is_constructible<Fn, LValueCallable>::value, "");
+        static_assert(!std::is_constructible<Fn, RValueCallable&>::value, "");
+        static_assert(!std::is_constructible<Fn, RValueCallable>::value, "");
+    }
+#endif
 }
index 11716e7..e927ad4 100644 (file)
@@ -19,6 +19,7 @@
 #include <functional>
 #include <cassert>
 
+#include "test_macros.h"
 #include "count_new.hpp"
 
 class A
@@ -52,6 +53,17 @@ int A::count = 0;
 
 int g(int) {return 0;}
 
+#if TEST_STD_VER >= 11
+struct RValueCallable {
+    template <class ...Args>
+    void operator()(Args&&...) && {}
+};
+struct LValueCallable {
+    template <class ...Args>
+    void operator()(Args&&...) & {}
+};
+#endif
+
 int main()
 {
     assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -95,4 +107,13 @@ int main()
     assert(f.target<int(*)(int)>() != 0);
     f(1);
     }
+#if TEST_STD_VER >= 11
+    {
+        using Fn = std::function<void(int, int, int)>;
+        static_assert(std::is_assignable<Fn&, LValueCallable&>::value, "");
+        static_assert(std::is_assignable<Fn&, LValueCallable>::value, "");
+        static_assert(!std::is_assignable<Fn&, RValueCallable&>::value, "");
+        static_assert(!std::is_assignable<Fn&, RValueCallable>::value, "");
+    }
+#endif
 }
index 352ecfc..e662b6c 100644 (file)
 #include <functional>
 #include <cassert>
 
+#include "test_macros.h"
 #include "min_allocator.h"
 #include "test_allocator.h"
 #include "count_new.hpp"
 #include "../function_types.h"
 
+
+#if TEST_STD_VER >= 11
+struct RValueCallable {
+    template <class ...Args>
+    void operator()(Args&&...) && {}
+};
+struct LValueCallable {
+    template <class ...Args>
+    void operator()(Args&&...) & {}
+};
+#endif
+
 class DummyClass {};
 
 template <class FuncType, class AllocType>
@@ -103,4 +116,14 @@ int main()
         non_default_test_allocator<DummyClass> non_default_alloc(42);
         test_for_alloc(non_default_alloc);
     }
+#if TEST_STD_VER >= 11
+    {
+        using Fn = std::function<void(int, int, int)>;
+        static_assert(std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, LValueCallable&>::value, "");
+        static_assert(std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, LValueCallable>::value, "");
+        static_assert(!std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, RValueCallable&>::value, "");
+        static_assert(!std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, RValueCallable>::value, "");
+    }
+#endif
+
 }
index db3eb83..5df7c98 100644 (file)
        <tr><td><a href="http://wg21.link/LWG2310">2310</a></td><td>Public exposition only member in std::array</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a href="http://wg21.link/LWG2312">2312</a></td><td>tuple's constructor constraints need to be phrased more precisely</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a href="http://wg21.link/LWG2328">2328</a></td><td>Rvalue stream extraction should use perfect forwarding</td><td>Oulu</td><td>Complete</td></tr>
-       <tr><td><a href="http://wg21.link/LWG2393">2393</a></td><td>std::function's Callable definition is broken</td><td>Oulu</td><td></td></tr>
+       <tr><td><a href="http://wg21.link/LWG2393">2393</a></td><td>std::function's Callable definition is broken</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a href="http://wg21.link/LWG2422">2422</a></td><td>std::numeric_limits&lt;T&gt;::is_modulo description: "most machines" errata</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a href="http://wg21.link/LWG2426">2426</a></td><td>Issue about compare_exchange</td><td>Oulu</td><td></td></tr>
        <tr><td><a href="http://wg21.link/LWG2436">2436</a></td><td>Comparators for associative containers should always be CopyConstructible</td><td>Oulu</td><td>Complete</td></tr>