[libcxx] r276546 - Implement LWG 2393. Check for LValue-callability.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 23 21:16:40 PDT 2016
Author: ericwf
Date: Sat Jul 23 23:16:40 2016
New Revision: 276546
URL: http://llvm.org/viewvc/llvm-project?rev=276546&view=rev
Log:
Implement LWG 2393. Check for LValue-callability.
Modified:
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp?rev=276546&r1=276545&r2=276546&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp Sat Jul 23 23:16:40 2016
@@ -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
}
Modified: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp?rev=276546&r1=276545&r2=276546&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp Sat Jul 23 23:16:40 2016
@@ -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
}
Modified: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp?rev=276546&r1=276545&r2=276546&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp Sat Jul 23 23:16:40 2016
@@ -16,11 +16,24 @@
#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
+
}
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=276546&r1=276545&r2=276546&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Sat Jul 23 23:16:40 2016
@@ -265,7 +265,7 @@
<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<T>::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>
More information about the cfe-commits
mailing list