Implement LWG 2393. Check for LValue-callability.

llvm-svn: 276546
This commit is contained in:
Eric Fiselier 2016-07-24 04:16:40 +00:00
parent 63c69ef49c
commit 790df14543
4 changed files with 66 additions and 1 deletions

View 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
}

View 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
}

View File

@ -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
}

View File

@ -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&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>