mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 20:29:39 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user