Implement LWG 2393. Check for LValue-callability.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276546 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-07-24 04:16:40 +00:00
parent 7f630e8ffa
commit e1a41a9f4d
4 changed files with 66 additions and 1 deletions

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
}