diff options
Diffstat (limited to 'test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con')
12 files changed, 12 insertions, 12 deletions
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp index 1cce02580..06368fe3e 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function(nullptr_t);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int foo(int) const {return 1;}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f = (int (*)(int))0;
assert(!f);
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
}
{
std::function<int(const A*, int)> f = &A::foo;
assert(f);
assert(new_called == 0);
assert(f.target<int (A::*)(int) const>() != 0);
}
}
\ No newline at end of file +//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function(nullptr_t);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int foo(int) const {return 1;}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f = (int (*)(int))0;
assert(!f);
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
}
{
std::function<int(const A*, int)> f = &A::foo;
assert(f);
assert(new_called == 0);
assert(f.target<int (A::*)(int) const>() != 0);
}
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp index 9b090f3e5..2d6ab4b94 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// template<class F>
// requires CopyConstructible<F> && Callable<F, ArgTypes..>
// && Convertible<Callable<F, ArgTypes...>::result_type
// operator=(F f);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int foo(int) const {return 1;}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f;
f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f;
f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f;
f = (int (*)(int))0;
assert(!f);
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
}
{
std::function<int(const A*, int)> f;
f = &A::foo;
assert(f);
assert(new_called == 0);
assert(f.target<int (A::*)(int) const>() != 0);
}
}
\ No newline at end of file +//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// template<class F>
// requires CopyConstructible<F> && Callable<F, ArgTypes..>
// && Convertible<Callable<F, ArgTypes...>::result_type
// operator=(F f);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int foo(int) const {return 1;}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f;
f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f;
f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f;
f = (int (*)(int))0;
assert(!f);
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
}
{
std::function<int(const A*, int)> f;
f = &A::foo;
assert(f);
assert(new_called == 0);
assert(f.target<int (A::*)(int) const>() != 0);
}
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp index bf2b33186..c66287185 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp @@ -1,6 +1,6 @@ //===----------------------------------------------------------------------===// // -// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp index e3a1e7b2b..01ffad74d 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp @@ -1,6 +1,6 @@ //===----------------------------------------------------------------------===// // -// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp index 3b55eb8df..893949cc6 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp @@ -1,6 +1,6 @@ //===----------------------------------------------------------------------===// // -// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp index 28edd858f..048b7f6bd 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp @@ -1,6 +1,6 @@ //===----------------------------------------------------------------------===// // -// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp index 2facbf7b5..15e4dad23 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp @@ -1,6 +1,6 @@ //===----------------------------------------------------------------------===// // -// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp index 78dcc58d8..d41975262 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function(const function& f);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2 = f;
assert(A::count == 2);
assert(new_called == 2);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
std::function<int(int)> f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f;
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
std::function<int(int)> f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
#ifdef _LIBCPP_MOVE
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2 = _STD::move(f);
assert(A::count == 1);
assert(new_called == 1);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
assert(f.target<int(*)(int)>() == 0);
}
#endif
}
\ No newline at end of file +//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function(const function& f);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2 = f;
assert(A::count == 2);
assert(new_called == 2);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
std::function<int(int)> f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f;
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
std::function<int(int)> f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
#ifdef _LIBCPP_MOVE
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2 = _STD::move(f);
assert(A::count == 1);
assert(new_called == 1);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
assert(f.target<int(*)(int)>() == 0);
}
#endif
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp index 2b168064e..2dc88a93c 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function& operator=(const function& f);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(A::count == 2);
assert(new_called == 2);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f;
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
#ifdef _LIBCPP_MOVE
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2;
f2 = _STD::move(f);
assert(A::count == 1);
assert(new_called == 1);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
assert(f.target<int(*)(int)>() == 0);
}
#endif
}
\ No newline at end of file +//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function& operator=(const function& f);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(A::count == 2);
assert(new_called == 2);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
assert(new_called == 0);
{
std::function<int(int)> f;
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(new_called == 0);
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
#ifdef _LIBCPP_MOVE
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2;
f2 = _STD::move(f);
assert(A::count == 1);
assert(new_called == 1);
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
assert(f.target<int(*)(int)>() == 0);
}
#endif
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp index b63544fc1..98e11620c 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// explicit function();
#include <functional>
#include <cassert>
int main()
{
std::function<int(int)> f;
assert(!f);
}
\ No newline at end of file +//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// explicit function();
#include <functional>
#include <cassert>
int main()
{
std::function<int(int)> f;
assert(!f);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp index e493ccfdb..e812070ff 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function(nullptr_t);
#include <functional>
#include <cassert>
int main()
{
std::function<int(int)> f(nullptr);
assert(!f);
}
\ No newline at end of file +//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function(nullptr_t);
#include <functional>
#include <cassert>
int main()
{
std::function<int(int)> f(nullptr);
assert(!f);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp index 4361d4a4a..aa00a04f1 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function& operator=(nullptr_t);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
f = nullptr;
assert(A::count == 0);
assert(new_called == 0);
assert(f.target<A>() == 0);
}
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
f = nullptr;
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
}
}
\ No newline at end of file +//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// class function<R(ArgTypes...)>
// function& operator=(nullptr_t);
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
class A
{
int data_[10];
public:
static int count;
A()
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = i;
}
A(const A&) {++count;}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
};
int A::count = 0;
int g(int) {return 0;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(new_called == 1);
assert(f.target<A>());
f = nullptr;
assert(A::count == 0);
assert(new_called == 0);
assert(f.target<A>() == 0);
}
{
std::function<int(int)> f = g;
assert(new_called == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
f = nullptr;
assert(new_called == 0);
assert(f.target<int(*)(int)>() == 0);
}
}
\ No newline at end of file |