diff options
Diffstat (limited to 'test/utilities/function.objects')
110 files changed, 110 insertions, 110 deletions
diff --git a/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp b/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp index 1b05252d9..c8528c230 100644 --- a/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp +++ b/test/utilities/function.objects/arithmetic.operations/divides.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>
// divides
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::divides<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(36, 4) == 9);
}
\ 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>
// divides
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::divides<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(36, 4) == 9);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp b/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp index 0667c9b39..e21d03f43 100644 --- a/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp +++ b/test/utilities/function.objects/arithmetic.operations/minus.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>
// minus
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::minus<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(3, 2) == 1);
}
\ 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>
// minus
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::minus<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(3, 2) == 1);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp b/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp index 4d8b4158a..393156966 100644 --- a/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp +++ b/test/utilities/function.objects/arithmetic.operations/modulus.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>
// modulus
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::modulus<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(36, 8) == 4);
}
\ 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>
// modulus
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::modulus<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(36, 8) == 4);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp b/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp index 4a92ef3bd..f020cd561 100644 --- a/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp +++ b/test/utilities/function.objects/arithmetic.operations/multiplies.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>
// multiplies
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::multiplies<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(3, 2) == 6);
}
\ 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>
// multiplies
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::multiplies<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(3, 2) == 6);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp b/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp index 832e5b076..59b56a3c6 100644 --- a/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp +++ b/test/utilities/function.objects/arithmetic.operations/negate.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>
// negate
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::negate<int> F;
const F f = F();
static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
assert(f(36) == -36);
}
\ 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>
// negate
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::negate<int> F;
const F f = F();
static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
assert(f(36) == -36);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp b/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp index 6a6e07eb4..2e922d2d0 100644 --- a/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp +++ b/test/utilities/function.objects/arithmetic.operations/plus.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>
// plus
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::plus<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(3, 2) == 5);
}
\ 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>
// plus
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::plus<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(3, 2) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/base/nothing_to_do.pass.cpp b/test/utilities/function.objects/base/nothing_to_do.pass.cpp index 923482612..e8db90cbe 100644 --- a/test/utilities/function.objects/base/nothing_to_do.pass.cpp +++ b/test/utilities/function.objects/base/nothing_to_do.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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp index e93043efe..28ec9d4b1 100644 --- a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <functional>
#include <cassert>
template <class R, class F>
void
test(F f, R expected)
{
assert(f() == expected);
}
template <class R, class F>
void
test_const(const F& f, R expected)
{
assert(f() == expected);
}
int f() {return 1;}
struct A_int_0
{
int operator()() {return 4;}
int operator()() const {return 5;}
};
int main()
{
test(std::bind(f), 1);
test(std::bind(&f), 1);
test(std::bind(A_int_0()), 4);
test_const(std::bind(A_int_0()), 5);
test(std::bind<int>(f), 1);
test(std::bind<int>(&f), 1);
test(std::bind<int>(A_int_0()), 4);
test_const(std::bind<int>(A_int_0()), 5);
}
\ 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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <functional>
#include <cassert>
template <class R, class F>
void
test(F f, R expected)
{
assert(f() == expected);
}
template <class R, class F>
void
test_const(const F& f, R expected)
{
assert(f() == expected);
}
int f() {return 1;}
struct A_int_0
{
int operator()() {return 4;}
int operator()() const {return 5;}
};
int main()
{
test(std::bind(f), 1);
test(std::bind(&f), 1);
test(std::bind(A_int_0()), 4);
test_const(std::bind(A_int_0()), 5);
test(std::bind<int>(f), 1);
test(std::bind<int>(&f), 1);
test(std::bind<int>(A_int_0()), 4);
test_const(std::bind<int>(A_int_0()), 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp index 8f87a0d98..84afdea2b 100644 --- a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <stdio.h>
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {count += 2;}
};
void
test_void_1()
{
using namespace std::placeholders;
int save_count = count;
// function
{
int i = 2;
std::bind(f_void_1, _1)(i);
assert(count == save_count + 2);
save_count = count;
}
{
int i = 2;
std::bind(f_void_1, i)();
assert(count == save_count + 2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
int i = 3;
std::bind(fp, _1)(i);
assert(count == save_count+3);
save_count = count;
}
{
void (*fp)(int) = f_void_1;
int i = 3;
std::bind(fp, i)();
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
int i = 4;
std::bind(a0, _1)(i);
assert(count == save_count+4);
save_count = count;
}
{
A_void_1 a0;
int i = 4;
std::bind(a0, i)();
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
A_void_1 a;
std::bind(fp, _1)(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, _1)(ap);
assert(count == save_count+1);
save_count = count;
}
{
void (A_void_1::*fp)() = &A_void_1::mem1;
A_void_1 a;
std::bind(fp, a)();
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, ap)();
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
A_void_1 a;
std::bind(fp, _1)(a);
assert(count == save_count+2);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, _1)(ap);
assert(count == save_count+2);
save_count = count;
}
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
A_void_1 a;
std::bind(fp, a)();
assert(count == save_count+2);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, ap)();
assert(count == save_count+2);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
using namespace std::placeholders;
// function
{
int i = 2;
assert(std::bind(f_int_1, _1)(i) == 3);
assert(std::bind(f_int_1, i)() == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
int i = 3;
assert(std::bind(fp, _1)(i) == 4);
assert(std::bind(fp, i)() == 4);
}
// functor
{
int i = 4;
assert(std::bind(A_int_1(), _1)(i) == 3);
assert(std::bind(A_int_1(), i)() == 3);
}
// member function pointer
{
A_int_1 a;
assert(std::bind(&A_int_1::mem1, _1)(a) == 3);
assert(std::bind(&A_int_1::mem1, a)() == 3);
A_int_1* ap = &a;
assert(std::bind(&A_int_1::mem1, _1)(ap) == 3);
assert(std::bind(&A_int_1::mem1, ap)() == 3);
}
// const member function pointer
{
A_int_1 a;
assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
A_int_1* ap = &a;
assert(std::bind(&A_int_1::mem2, _1)(ap) == 4);
assert(std::bind(&A_int_1::mem2, ap)() == 4);
}
// member data pointer
{
A_int_1 a;
assert(std::bind(&A_int_1::data_, _1)(a) == 5);
assert(std::bind(&A_int_1::data_, a)() == 5);
A_int_1* ap = &a;
assert(std::bind(&A_int_1::data_, _1)(a) == 5);
std::bind(&A_int_1::data_, _1)(a) = 6;
assert(std::bind(&A_int_1::data_, _1)(a) == 6);
assert(std::bind(&A_int_1::data_, _1)(ap) == 6);
std::bind(&A_int_1::data_, _1)(ap) = 7;
assert(std::bind(&A_int_1::data_, _1)(ap) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
using namespace std::placeholders;
int save_count = count;
// function
{
int i = 2;
int j = 3;
std::bind(f_void_2, _1, _2)(i, j);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, i, _1)(j);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, i, j)();
assert(count == save_count+5);
save_count = count;
}
// member function pointer
{
int j = 3;
std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), j);
assert(count == save_count+3);
save_count = count;
std::bind(&A_void_2::mem1, _2, _1)(j, A_void_2());
assert(count == save_count+3);
save_count = count;
}
}
int main()
{
test_void_1();
test_int_1();
}
\ 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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <stdio.h>
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {count += 2;}
};
void
test_void_1()
{
using namespace std::placeholders;
int save_count = count;
// function
{
int i = 2;
std::bind(f_void_1, _1)(i);
assert(count == save_count + 2);
save_count = count;
}
{
int i = 2;
std::bind(f_void_1, i)();
assert(count == save_count + 2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
int i = 3;
std::bind(fp, _1)(i);
assert(count == save_count+3);
save_count = count;
}
{
void (*fp)(int) = f_void_1;
int i = 3;
std::bind(fp, i)();
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
int i = 4;
std::bind(a0, _1)(i);
assert(count == save_count+4);
save_count = count;
}
{
A_void_1 a0;
int i = 4;
std::bind(a0, i)();
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
A_void_1 a;
std::bind(fp, _1)(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, _1)(ap);
assert(count == save_count+1);
save_count = count;
}
{
void (A_void_1::*fp)() = &A_void_1::mem1;
A_void_1 a;
std::bind(fp, a)();
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, ap)();
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
A_void_1 a;
std::bind(fp, _1)(a);
assert(count == save_count+2);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, _1)(ap);
assert(count == save_count+2);
save_count = count;
}
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
A_void_1 a;
std::bind(fp, a)();
assert(count == save_count+2);
save_count = count;
A_void_1* ap = &a;
std::bind(fp, ap)();
assert(count == save_count+2);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
using namespace std::placeholders;
// function
{
int i = 2;
assert(std::bind(f_int_1, _1)(i) == 3);
assert(std::bind(f_int_1, i)() == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
int i = 3;
assert(std::bind(fp, _1)(i) == 4);
assert(std::bind(fp, i)() == 4);
}
// functor
{
int i = 4;
assert(std::bind(A_int_1(), _1)(i) == 3);
assert(std::bind(A_int_1(), i)() == 3);
}
// member function pointer
{
A_int_1 a;
assert(std::bind(&A_int_1::mem1, _1)(a) == 3);
assert(std::bind(&A_int_1::mem1, a)() == 3);
A_int_1* ap = &a;
assert(std::bind(&A_int_1::mem1, _1)(ap) == 3);
assert(std::bind(&A_int_1::mem1, ap)() == 3);
}
// const member function pointer
{
A_int_1 a;
assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
A_int_1* ap = &a;
assert(std::bind(&A_int_1::mem2, _1)(ap) == 4);
assert(std::bind(&A_int_1::mem2, ap)() == 4);
}
// member data pointer
{
A_int_1 a;
assert(std::bind(&A_int_1::data_, _1)(a) == 5);
assert(std::bind(&A_int_1::data_, a)() == 5);
A_int_1* ap = &a;
assert(std::bind(&A_int_1::data_, _1)(a) == 5);
std::bind(&A_int_1::data_, _1)(a) = 6;
assert(std::bind(&A_int_1::data_, _1)(a) == 6);
assert(std::bind(&A_int_1::data_, _1)(ap) == 6);
std::bind(&A_int_1::data_, _1)(ap) = 7;
assert(std::bind(&A_int_1::data_, _1)(ap) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
using namespace std::placeholders;
int save_count = count;
// function
{
int i = 2;
int j = 3;
std::bind(f_void_2, _1, _2)(i, j);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, i, _1)(j);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, i, j)();
assert(count == save_count+5);
save_count = count;
}
// member function pointer
{
int j = 3;
std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), j);
assert(count == save_count+3);
save_count = count;
std::bind(&A_void_2::mem1, _2, _1)(j, A_void_2());
assert(count == save_count+3);
save_count = count;
}
}
int main()
{
test_void_1();
test_int_1();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp index 1340a0cc8..508caee69 100644 --- a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <stdio.h>
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {count += 2;}
};
void
test_void_1()
{
using namespace std::placeholders;
int save_count = count;
// function
{
std::bind(f_void_1, _1)(2);
assert(count == save_count + 2);
save_count = count;
}
{
std::bind(f_void_1, 2)();
assert(count == save_count + 2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
std::bind(fp, _1)(3);
assert(count == save_count+3);
save_count = count;
}
{
void (*fp)(int) = f_void_1;
std::bind(fp, 3)();
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
std::bind(a0, _1)(4);
assert(count == save_count+4);
save_count = count;
}
{
A_void_1 a0;
std::bind(a0, 4)();
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::bind(fp, _1)(A_void_1());
assert(count == save_count+1);
save_count = count;
A_void_1 a;
std::bind(fp, _1)(&a);
assert(count == save_count+1);
save_count = count;
}
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::bind(fp, A_void_1())();
assert(count == save_count+1);
save_count = count;
A_void_1 a;
std::bind(fp, &a)();
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::bind(fp, _1)(A_void_1());
assert(count == save_count+2);
save_count = count;
A_void_1 a;
std::bind(fp, _1)(&a);
assert(count == save_count+2);
save_count = count;
}
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::bind(fp, A_void_1())();
assert(count == save_count+2);
save_count = count;
A_void_1 a;
std::bind(fp, &a)();
assert(count == save_count+2);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
using namespace std::placeholders;
// function
{
assert(std::bind(f_int_1, _1)(2) == 3);
assert(std::bind(f_int_1, 2)() == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
assert(std::bind(fp, _1)(3) == 4);
assert(std::bind(fp, 3)() == 4);
}
// functor
{
assert(std::bind(A_int_1(), _1)(4) == 3);
assert(std::bind(A_int_1(), 4)() == 3);
}
// member function pointer
{
assert(std::bind(&A_int_1::mem1, _1)(A_int_1()) == 3);
assert(std::bind(&A_int_1::mem1, A_int_1())() == 3);
A_int_1 a;
assert(std::bind(&A_int_1::mem1, _1)(&a) == 3);
assert(std::bind(&A_int_1::mem1, &a)() == 3);
}
// const member function pointer
{
assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
A_int_1 a;
assert(std::bind(&A_int_1::mem2, _1)(&a) == 4);
assert(std::bind(&A_int_1::mem2, &a)() == 4);
}
// member data pointer
{
assert(std::bind(&A_int_1::data_, _1)(A_int_1()) == 5);
assert(std::bind(&A_int_1::data_, A_int_1())() == 5);
A_int_1 a;
assert(std::bind(&A_int_1::data_, _1)(a) == 5);
std::bind(&A_int_1::data_, _1)(a) = 6;
assert(std::bind(&A_int_1::data_, _1)(a) == 6);
assert(std::bind(&A_int_1::data_, _1)(&a) == 6);
std::bind(&A_int_1::data_, _1)(&a) = 7;
assert(std::bind(&A_int_1::data_, _1)(&a) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
using namespace std::placeholders;
int save_count = count;
// function
{
std::bind(f_void_2, _1, _2)(2, 3);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, 2, _1)(3);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, 2, 3)();
assert(count == save_count+5);
save_count = count;
}
// member function pointer
{
std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), 3);
assert(count == save_count+3);
save_count = count;
std::bind(&A_void_2::mem1, _2, _1)(3, A_void_2());
assert(count == save_count+3);
save_count = count;
}
}
int main()
{
test_void_1();
test_int_1();
}
\ 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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <stdio.h>
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {count += 2;}
};
void
test_void_1()
{
using namespace std::placeholders;
int save_count = count;
// function
{
std::bind(f_void_1, _1)(2);
assert(count == save_count + 2);
save_count = count;
}
{
std::bind(f_void_1, 2)();
assert(count == save_count + 2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
std::bind(fp, _1)(3);
assert(count == save_count+3);
save_count = count;
}
{
void (*fp)(int) = f_void_1;
std::bind(fp, 3)();
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
std::bind(a0, _1)(4);
assert(count == save_count+4);
save_count = count;
}
{
A_void_1 a0;
std::bind(a0, 4)();
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::bind(fp, _1)(A_void_1());
assert(count == save_count+1);
save_count = count;
A_void_1 a;
std::bind(fp, _1)(&a);
assert(count == save_count+1);
save_count = count;
}
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::bind(fp, A_void_1())();
assert(count == save_count+1);
save_count = count;
A_void_1 a;
std::bind(fp, &a)();
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::bind(fp, _1)(A_void_1());
assert(count == save_count+2);
save_count = count;
A_void_1 a;
std::bind(fp, _1)(&a);
assert(count == save_count+2);
save_count = count;
}
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::bind(fp, A_void_1())();
assert(count == save_count+2);
save_count = count;
A_void_1 a;
std::bind(fp, &a)();
assert(count == save_count+2);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
using namespace std::placeholders;
// function
{
assert(std::bind(f_int_1, _1)(2) == 3);
assert(std::bind(f_int_1, 2)() == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
assert(std::bind(fp, _1)(3) == 4);
assert(std::bind(fp, 3)() == 4);
}
// functor
{
assert(std::bind(A_int_1(), _1)(4) == 3);
assert(std::bind(A_int_1(), 4)() == 3);
}
// member function pointer
{
assert(std::bind(&A_int_1::mem1, _1)(A_int_1()) == 3);
assert(std::bind(&A_int_1::mem1, A_int_1())() == 3);
A_int_1 a;
assert(std::bind(&A_int_1::mem1, _1)(&a) == 3);
assert(std::bind(&A_int_1::mem1, &a)() == 3);
}
// const member function pointer
{
assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
A_int_1 a;
assert(std::bind(&A_int_1::mem2, _1)(&a) == 4);
assert(std::bind(&A_int_1::mem2, &a)() == 4);
}
// member data pointer
{
assert(std::bind(&A_int_1::data_, _1)(A_int_1()) == 5);
assert(std::bind(&A_int_1::data_, A_int_1())() == 5);
A_int_1 a;
assert(std::bind(&A_int_1::data_, _1)(a) == 5);
std::bind(&A_int_1::data_, _1)(a) = 6;
assert(std::bind(&A_int_1::data_, _1)(a) == 6);
assert(std::bind(&A_int_1::data_, _1)(&a) == 6);
std::bind(&A_int_1::data_, _1)(&a) = 7;
assert(std::bind(&A_int_1::data_, _1)(&a) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
using namespace std::placeholders;
int save_count = count;
// function
{
std::bind(f_void_2, _1, _2)(2, 3);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, 2, _1)(3);
assert(count == save_count+5);
save_count = count;
std::bind(f_void_2, 2, 3)();
assert(count == save_count+5);
save_count = count;
}
// member function pointer
{
std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), 3);
assert(count == save_count+3);
save_count = count;
std::bind(&A_void_2::mem1, _2, _1)(3, A_void_2());
assert(count == save_count+3);
save_count = count;
}
}
int main()
{
test_void_1();
test_int_1();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp index 0eb0c0690..d9d7e94df 100644 --- a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <functional>
#include <cassert>
int count = 0;
template <class F>
void
test(F f)
{
int save_count = count;
f();
assert(count == save_count + 1);
}
template <class F>
void
test_const(const F& f)
{
int save_count = count;
f();
assert(count == save_count + 2);
}
void f() {++count;}
struct A_int_0
{
void operator()() {++count;}
void operator()() const {count += 2;}
};
int main()
{
test(std::bind(f));
test(std::bind(&f));
test(std::bind(A_int_0()));
test_const(std::bind(A_int_0()));
test(std::bind<void>(f));
test(std::bind<void>(&f));
test(std::bind<void>(A_int_0()));
test_const(std::bind<void>(A_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>
// template<CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
#include <functional>
#include <cassert>
int count = 0;
template <class F>
void
test(F f)
{
int save_count = count;
f();
assert(count == save_count + 1);
}
template <class F>
void
test_const(const F& f)
{
int save_count = count;
f();
assert(count == save_count + 2);
}
void f() {++count;}
struct A_int_0
{
void operator()() {++count;}
void operator()() const {count += 2;}
};
int main()
{
test(std::bind(f));
test(std::bind(&f));
test(std::bind(A_int_0()));
test_const(std::bind(A_int_0()));
test(std::bind<void>(f));
test(std::bind<void>(&f));
test(std::bind<void>(A_int_0()));
test_const(std::bind<void>(A_int_0()));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp index 341cf2748..54c44a666 100644 --- a/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.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>
// template<class T> struct is_bind_expression
#include <functional>
template <bool Expected, class T>
void
test(const T&)
{
static_assert(std::is_bind_expression<T>::value == Expected, "");
}
struct C {};
int main()
{
test<true>(std::bind(C()));
test<true>(std::bind(C(), std::placeholders::_2));
test<true>(std::bind<int>(C()));
test<false>(1);
test<false>(std::placeholders::_2);
}
\ 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>
// template<class T> struct is_bind_expression
#include <functional>
template <bool Expected, class T>
void
test(const T&)
{
static_assert(std::is_bind_expression<T>::value == Expected, "");
}
struct C {};
int main()
{
test<true>(std::bind(C()));
test<true>(std::bind(C(), std::placeholders::_2));
test<true>(std::bind<int>(C()));
test<false>(1);
test<false>(std::placeholders::_2);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp index eebe80b8a..93fca7be2 100644 --- a/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.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>
// struct is_placeholder
#include <functional>
template <int Expected, class T>
void
test(const T&)
{
static_assert(std::is_placeholder<T>::value == Expected, "");
}
struct C {};
int main()
{
test<1>(std::placeholders::_1);
test<2>(std::placeholders::_2);
test<3>(std::placeholders::_3);
test<4>(std::placeholders::_4);
test<5>(std::placeholders::_5);
test<6>(std::placeholders::_6);
test<7>(std::placeholders::_7);
test<8>(std::placeholders::_8);
test<9>(std::placeholders::_9);
test<10>(std::placeholders::_10);
test<0>(4);
test<0>(5.5);
test<0>('a');
test<0>(C());
}
\ 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>
// struct is_placeholder
#include <functional>
template <int Expected, class T>
void
test(const T&)
{
static_assert(std::is_placeholder<T>::value == Expected, "");
}
struct C {};
int main()
{
test<1>(std::placeholders::_1);
test<2>(std::placeholders::_2);
test<3>(std::placeholders::_3);
test<4>(std::placeholders::_4);
test<5>(std::placeholders::_5);
test<6>(std::placeholders::_6);
test<7>(std::placeholders::_7);
test<8>(std::placeholders::_8);
test<9>(std::placeholders::_9);
test<10>(std::placeholders::_10);
test<0>(4);
test<0>(5.5);
test<0>('a');
test<0>(C());
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp index 5b54c2412..0414f62c8 100644 --- a/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.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>
// placeholders
#include <functional>
template <class T>
void
test(const T& t)
{
T t2;
T t3 = t;
}
int main()
{
test(std::placeholders::_1);
test(std::placeholders::_2);
test(std::placeholders::_3);
test(std::placeholders::_4);
test(std::placeholders::_5);
test(std::placeholders::_6);
test(std::placeholders::_7);
test(std::placeholders::_8);
test(std::placeholders::_9);
test(std::placeholders::_10);
}
\ 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>
// placeholders
#include <functional>
template <class T>
void
test(const T& t)
{
T t2;
T t3 = t;
}
int main()
{
test(std::placeholders::_1);
test(std::placeholders::_2);
test(std::placeholders::_3);
test(std::placeholders::_4);
test(std::placeholders::_5);
test(std::placeholders::_6);
test(std::placeholders::_7);
test(std::placeholders::_8);
test(std::placeholders::_9);
test(std::placeholders::_10);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp b/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp index 923482612..e8db90cbe 100644 --- a/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp +++ b/test/utilities/function.objects/bind/func.bind/nothing_to_do.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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bind/nothing_to_do.pass.cpp b/test/utilities/function.objects/bind/nothing_to_do.pass.cpp index 923482612..e8db90cbe 100644 --- a/test/utilities/function.objects/bind/nothing_to_do.pass.cpp +++ b/test/utilities/function.objects/bind/nothing_to_do.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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp b/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp index 6addf35e7..b334dac7f 100644 --- a/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp +++ b/test/utilities/function.objects/bitwise.operations/bit_and.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>
// bit_and
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::bit_and<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(0xEA95, 0xEA95) == 0xEA95);
assert(f(0xEA95, 0x58D3) == 0x4891);
assert(f(0x58D3, 0xEA95) == 0x4891);
assert(f(0x58D3, 0) == 0);
assert(f(0xFFFF, 0x58D3) == 0x58D3);
}
\ 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>
// bit_and
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::bit_and<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(0xEA95, 0xEA95) == 0xEA95);
assert(f(0xEA95, 0x58D3) == 0x4891);
assert(f(0x58D3, 0xEA95) == 0x4891);
assert(f(0x58D3, 0) == 0);
assert(f(0xFFFF, 0x58D3) == 0x58D3);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp b/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp index ef546841b..227863b48 100644 --- a/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp +++ b/test/utilities/function.objects/bitwise.operations/bit_or.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>
// bit_or
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::bit_or<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(0xEA95, 0xEA95) == 0xEA95);
assert(f(0xEA95, 0x58D3) == 0xFAD7);
assert(f(0x58D3, 0xEA95) == 0xFAD7);
assert(f(0x58D3, 0) == 0x58D3);
assert(f(0xFFFF, 0x58D3) == 0xFFFF);
}
\ 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>
// bit_or
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::bit_or<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(0xEA95, 0xEA95) == 0xEA95);
assert(f(0xEA95, 0x58D3) == 0xFAD7);
assert(f(0x58D3, 0xEA95) == 0xFAD7);
assert(f(0x58D3, 0) == 0x58D3);
assert(f(0xFFFF, 0x58D3) == 0xFFFF);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp b/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp index 139763d88..657498f69 100644 --- a/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp +++ b/test/utilities/function.objects/bitwise.operations/bit_xor.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>
// bit_xor
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::bit_xor<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(0xEA95, 0xEA95) == 0);
assert(f(0xEA95, 0x58D3) == 0xB246);
assert(f(0x58D3, 0xEA95) == 0xB246);
assert(f(0x58D3, 0) == 0x58D3);
assert(f(0xFFFF, 0x58D3) == 0xA72C);
}
\ 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>
// bit_xor
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::bit_xor<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
assert(f(0xEA95, 0xEA95) == 0);
assert(f(0xEA95, 0x58D3) == 0xB246);
assert(f(0x58D3, 0xEA95) == 0xB246);
assert(f(0x58D3, 0) == 0x58D3);
assert(f(0xFFFF, 0x58D3) == 0xA72C);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/comparisons/equal_to.pass.cpp b/test/utilities/function.objects/comparisons/equal_to.pass.cpp index 55796f827..282d41021 100644 --- a/test/utilities/function.objects/comparisons/equal_to.pass.cpp +++ b/test/utilities/function.objects/comparisons/equal_to.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>
// equal_to
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::equal_to<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(!f(36, 6));
}
\ 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>
// equal_to
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::equal_to<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(!f(36, 6));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/comparisons/greater.pass.cpp b/test/utilities/function.objects/comparisons/greater.pass.cpp index ee36c538c..4595c9742 100644 --- a/test/utilities/function.objects/comparisons/greater.pass.cpp +++ b/test/utilities/function.objects/comparisons/greater.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>
// greater
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::greater<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert(f(36, 6));
assert(!f(6, 36));
}
\ 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>
// greater
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::greater<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert(f(36, 6));
assert(!f(6, 36));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/comparisons/greater_equal.pass.cpp b/test/utilities/function.objects/comparisons/greater_equal.pass.cpp index a6d114c67..52089e079 100644 --- a/test/utilities/function.objects/comparisons/greater_equal.pass.cpp +++ b/test/utilities/function.objects/comparisons/greater_equal.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>
// greater_equal
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::greater_equal<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(f(36, 6));
assert(!f(6, 36));
}
\ 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>
// greater_equal
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::greater_equal<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(f(36, 6));
assert(!f(6, 36));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/comparisons/less.pass.cpp b/test/utilities/function.objects/comparisons/less.pass.cpp index 6a40ba049..178378a4f 100644 --- a/test/utilities/function.objects/comparisons/less.pass.cpp +++ b/test/utilities/function.objects/comparisons/less.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>
// less
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::less<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert(!f(36, 6));
assert(f(6, 36));
}
\ 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>
// less
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::less<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert(!f(36, 6));
assert(f(6, 36));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/comparisons/less_equal.pass.cpp b/test/utilities/function.objects/comparisons/less_equal.pass.cpp index 849767017..9df852816 100644 --- a/test/utilities/function.objects/comparisons/less_equal.pass.cpp +++ b/test/utilities/function.objects/comparisons/less_equal.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>
// less_equal
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::less_equal<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(!f(36, 6));
assert(f(6, 36));
}
\ 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>
// less_equal
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::less_equal<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(!f(36, 6));
assert(f(6, 36));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp index fb99ee56b..d3793340c 100644 --- a/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp +++ b/test/utilities/function.objects/comparisons/not_equal_to.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>
// not_equal_to
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::not_equal_to<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert(f(36, 6));
}
\ 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>
// not_equal_to
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::not_equal_to<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert(f(36, 6));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp b/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp index 923482612..e8db90cbe 100644 --- a/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp +++ b/test/utilities/function.objects/func.def/nothing_to_do.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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.memfn/member_data.fail.cpp b/test/utilities/function.objects/func.memfn/member_data.fail.cpp index 4cc664480..4a284d251 100644 --- a/test/utilities/function.objects/func.memfn/member_data.fail.cpp +++ b/test/utilities/function.objects/func.memfn/member_data.fail.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>
// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
#include <functional>
#include <cassert>
struct A
{
double data_;
};
template <class F>
void
test(F f)
{
{
A a;
f(a) = 5;
assert(a.data_ == 5);
A* ap = &a;
f(ap) = 6;
assert(a.data_ == 6);
const A* cap = ap;
assert(f(cap) == f(ap));
f(cap) = 7;
}
}
int main()
{
test(std::mem_fn(&A::data_));
}
\ 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>
// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
#include <functional>
#include <cassert>
struct A
{
double data_;
};
template <class F>
void
test(F f)
{
{
A a;
f(a) = 5;
assert(a.data_ == 5);
A* ap = &a;
f(ap) = 6;
assert(a.data_ == 6);
const A* cap = ap;
assert(f(cap) == f(ap));
f(cap) = 7;
}
}
int main()
{
test(std::mem_fn(&A::data_));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.memfn/member_data.pass.cpp b/test/utilities/function.objects/func.memfn/member_data.pass.cpp index 303097e93..54cf2d3df 100644 --- a/test/utilities/function.objects/func.memfn/member_data.pass.cpp +++ b/test/utilities/function.objects/func.memfn/member_data.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>
// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
#include <functional>
#include <cassert>
struct A
{
double data_;
};
template <class F>
void
test(F f)
{
{
A a;
f(a) = 5;
assert(a.data_ == 5);
A* ap = &a;
f(ap) = 6;
assert(a.data_ == 6);
const A* cap = ap;
assert(f(cap) == f(ap));
}
}
int main()
{
test(std::mem_fn(&A::data_));
}
\ 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>
// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
#include <functional>
#include <cassert>
struct A
{
double data_;
};
template <class F>
void
test(F f)
{
{
A a;
f(a) = 5;
assert(a.data_ == 5);
A* ap = &a;
f(ap) = 6;
assert(a.data_ == 6);
const A* cap = ap;
assert(f(cap) == f(ap));
}
}
int main()
{
test(std::mem_fn(&A::data_));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.memfn/member_function.pass.cpp b/test/utilities/function.objects/func.memfn/member_function.pass.cpp index 774a507a4..5995c618c 100644 --- a/test/utilities/function.objects/func.memfn/member_function.pass.cpp +++ b/test/utilities/function.objects/func.memfn/member_function.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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...));
#include <functional>
#include <cassert>
struct A
{
char test0() {return 'a';}
char test1(int) {return 'b';}
char test2(int, double) {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ 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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...));
#include <functional>
#include <cassert>
struct A
{
char test0() {return 'a';}
char test1(int) {return 'b';}
char test2(int, double) {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp b/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp index b8b24d9c1..f927474b4 100644 --- a/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp +++ b/test/utilities/function.objects/func.memfn/member_function_const.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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...) const);
#include <functional>
#include <cassert>
struct A
{
char test0() const {return 'a';}
char test1(int) const {return 'b';}
char test2(int, double) const {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
const A* cap = &a;
assert(f(cap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
const A* cap = &a;
assert(f(cap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
const A* cap = &a;
assert(f(cap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ 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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...) const);
#include <functional>
#include <cassert>
struct A
{
char test0() const {return 'a';}
char test1(int) const {return 'b';}
char test2(int, double) const {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
const A* cap = &a;
assert(f(cap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
const A* cap = &a;
assert(f(cap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
const A* cap = &a;
assert(f(cap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp b/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp index 9523f537b..a33c13c56 100644 --- a/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp +++ b/test/utilities/function.objects/func.memfn/member_function_const_volatile.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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...) const volatile);
#include <functional>
#include <cassert>
struct A
{
char test0() const volatile {return 'a';}
char test1(int) const volatile {return 'b';}
char test2(int, double) const volatile {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
const volatile A* cap = &a;
assert(f(cap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
const volatile A* cap = &a;
assert(f(cap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
const volatile A* cap = &a;
assert(f(cap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ 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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...) const volatile);
#include <functional>
#include <cassert>
struct A
{
char test0() const volatile {return 'a';}
char test1(int) const volatile {return 'b';}
char test2(int, double) const volatile {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
const volatile A* cap = &a;
assert(f(cap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
const volatile A* cap = &a;
assert(f(cap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
const volatile A* cap = &a;
assert(f(cap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp b/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp index bf028b3cf..3f445f5fb 100644 --- a/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp +++ b/test/utilities/function.objects/func.memfn/member_function_volatile.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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...) volatile);
#include <functional>
#include <cassert>
struct A
{
char test0() volatile {return 'a';}
char test1(int) volatile {return 'b';}
char test2(int, double) volatile {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
volatile A* cap = &a;
assert(f(cap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
volatile A* cap = &a;
assert(f(cap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
volatile A* cap = &a;
assert(f(cap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ 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>
// template<Returnable R, class T, CopyConstructible... Args>
// unspecified mem_fn(R (T::* pm)(Args...) volatile);
#include <functional>
#include <cassert>
struct A
{
char test0() volatile {return 'a';}
char test1(int) volatile {return 'b';}
char test2(int, double) volatile {return 'c';}
};
template <class F>
void
test0(F f)
{
{
A a;
assert(f(a) == 'a');
A* ap = &a;
assert(f(ap) == 'a');
volatile A* cap = &a;
assert(f(cap) == 'a');
}
}
template <class F>
void
test1(F f)
{
{
A a;
assert(f(a, 1) == 'b');
A* ap = &a;
assert(f(ap, 2) == 'b');
volatile A* cap = &a;
assert(f(cap, 2) == 'b');
}
}
template <class F>
void
test2(F f)
{
{
A a;
assert(f(a, 1, 2) == 'c');
A* ap = &a;
assert(f(ap, 2, 3.5) == 'c');
volatile A* cap = &a;
assert(f(cap, 2, 3.5) == 'c');
}
}
int main()
{
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.require/binary_function.pass.cpp b/test/utilities/function.objects/func.require/binary_function.pass.cpp index e03dfe2c7..53ac5c57f 100644 --- a/test/utilities/function.objects/func.require/binary_function.pass.cpp +++ b/test/utilities/function.objects/func.require/binary_function.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>
// binary_function
#include <functional>
#include <type_traits>
int main()
{
typedef std::binary_function<int, short, bool> bf;
static_assert((std::is_same<bf::first_argument_type, int>::value), "");
static_assert((std::is_same<bf::second_argument_type, short>::value), "");
static_assert((std::is_same<bf::result_type, bool>::value), "");
}
\ 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>
// binary_function
#include <functional>
#include <type_traits>
int main()
{
typedef std::binary_function<int, short, bool> bf;
static_assert((std::is_same<bf::first_argument_type, int>::value), "");
static_assert((std::is_same<bf::second_argument_type, short>::value), "");
static_assert((std::is_same<bf::result_type, bool>::value), "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.require/unary_function.pass.cpp b/test/utilities/function.objects/func.require/unary_function.pass.cpp index b5c944cff..5f251260e 100644 --- a/test/utilities/function.objects/func.require/unary_function.pass.cpp +++ b/test/utilities/function.objects/func.require/unary_function.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>
// unary_function
#include <functional>
#include <type_traits>
int main()
{
typedef std::unary_function<int, bool> uf;
static_assert((std::is_same<uf::argument_type, int>::value), "");
static_assert((std::is_same<uf::result_type, bool>::value), "");
}
\ 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>
// unary_function
#include <functional>
#include <type_traits>
int main()
{
typedef std::unary_function<int, bool> uf;
static_assert((std::is_same<uf::argument_type, int>::value), "");
static_assert((std::is_same<uf::result_type, bool>::value), "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp index 22af67ebf..b39198f8d 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.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.
//
//===----------------------------------------------------------------------===//
// Class bad_function_call
// class bad_function_call
// : public exception
// {
// public:
// // 20.7.16.1.1, constructor:
// bad_function_call();
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((std::is_base_of<std::exception, std::bad_function_call>::value), "");
}
\ 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.
//
//===----------------------------------------------------------------------===//
// Class bad_function_call
// class bad_function_call
// : public exception
// {
// public:
// // 20.7.16.1.1, constructor:
// bad_function_call();
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((std::is_base_of<std::exception, std::bad_function_call>::value), "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp index 682399afa..d9fb5fd1d 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.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.
//
//===----------------------------------------------------------------------===//
// Class bad_function_call
// bad_function_call();
#include <functional>
#include <type_traits>
int main()
{
std::bad_function_call ex;
}
\ 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.
//
//===----------------------------------------------------------------------===//
// Class bad_function_call
// bad_function_call();
#include <functional>
#include <type_traits>
int main()
{
std::bad_function_call ex;
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp index b21c5522d..12f95a720 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.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 <MoveConstructible R, MoveConstructible ... ArgTypes>
// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
#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;
explicit A(int j)
{
++count;
data_[0] = j;
}
A(const A& a)
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = a.data_[i];
}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int id() const {return data_[0];}
};
int A::count = 0;
int g(int) {return 0;}
int h(int) {return 1;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = A(2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 1);
assert(f2.target<A>()->id() == 2);
swap(f1, f2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 2);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = g;
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
swap(f1, f2);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = A(1);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
swap(f1, f2);
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = h;
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == g);
assert(*f2.target<int(*)(int)>() == h);
swap(f1, f2);
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == h);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 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 <MoveConstructible R, MoveConstructible ... ArgTypes>
// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
#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;
explicit A(int j)
{
++count;
data_[0] = j;
}
A(const A& a)
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = a.data_[i];
}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int id() const {return data_[0];}
};
int A::count = 0;
int g(int) {return 0;}
int h(int) {return 1;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = A(2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 1);
assert(f2.target<A>()->id() == 2);
swap(f1, f2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 2);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = g;
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
swap(f1, f2);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = A(1);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
swap(f1, f2);
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = h;
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == g);
assert(*f2.target<int(*)(int)>() == h);
swap(f1, f2);
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == h);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 0);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp index 6ecb53124..44327baed 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.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 operator bool() const
#include <functional>
#include <cassert>
int g(int) {return 0;}
int main()
{
{
std::function<int(int)> f;
assert(!f);
f = g;
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 operator bool() const
#include <functional>
#include <cassert>
int g(int) {return 0;}
int main()
{
{
std::function<int(int)> f;
assert(!f);
f = g;
assert(f);
}
}
\ No newline at end of file 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 diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp index e3626ef3c..9df88e8c1 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <cassert>
// member data pointer: cv qualifiers should transfer from argument to return type
struct A_int_1
{
A_int_1() : data_(5) {}
int data_;
};
void
test_int_1()
{
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
A_int_1 a;
std::function<int& (const A_int_1*)> r2(fp);
const A_int_1* ap = &a;
assert(r2(ap) == 6);
r2(ap) = 7;
assert(r2(ap) == 7);
}
}
int main()
{
test_int_1();
}
\ 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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <cassert>
// member data pointer: cv qualifiers should transfer from argument to return type
struct A_int_1
{
A_int_1() : data_(5) {}
int data_;
};
void
test_int_1()
{
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
A_int_1 a;
std::function<int& (const A_int_1*)> r2(fp);
const A_int_1* ap = &a;
assert(r2(ap) == 6);
r2(ap) = 7;
assert(r2(ap) == 7);
}
}
int main()
{
test_int_1();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp index 4babee7af..f95f082cf 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {++count;}
};
void
test_void_1()
{
int save_count = count;
// function
{
std::function<void (int)> r1(f_void_1);
int i = 2;
r1(i);
assert(count == save_count+2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
std::function<void (int)> r1(fp);
int i = 3;
r1(i);
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
std::function<void (int)> r1(a0);
int i = 4;
r1(i);
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::function<void (A_void_1)> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
std::function<void (A_void_1*)> r2 = fp;
r2(ap);
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::function<void (A_void_1)> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
std::function<void (A_void_1*)> r2(fp);
A_void_1* ap = &a;
r2(ap);
assert(count == save_count+1);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
// function
{
std::function<int (int)> r1(f_int_1);
int i = 2;
assert(r1(i) == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
std::function<int (int)> r1(fp);
int i = 3;
assert(r1(i) == 4);
}
// functor
{
A_int_1 a0;
std::function<int (int)> r1(a0);
int i = 4;
assert(r1(i) == 3);
}
// member function pointer
{
int (A_int_1::*fp)() = &A_int_1::mem1;
std::function<int (A_int_1)> r1(fp);
A_int_1 a;
assert(r1(a) == 3);
std::function<int (A_int_1*)> r2(fp);
A_int_1* ap = &a;
assert(r2(ap) == 3);
}
// const member function pointer
{
int (A_int_1::*fp)() const = &A_int_1::mem2;
std::function<int (A_int_1)> r1(fp);
A_int_1 a;
assert(r1(a) == 4);
std::function<int (A_int_1*)> r2(fp);
A_int_1* ap = &a;
assert(r2(ap) == 4);
}
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
std::function<int& (A_int_1&)> r1(fp);
A_int_1 a;
assert(r1(a) == 5);
r1(a) = 6;
assert(r1(a) == 6);
std::function<int& (A_int_1*)> r2(fp);
A_int_1* ap = &a;
assert(r2(ap) == 6);
r2(ap) = 7;
assert(r2(ap) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
int save_count = count;
// function
{
std::function<void (int, int)> r1(f_void_2);
int i = 2;
int j = 3;
r1(i, j);
assert(count == save_count+5);
save_count = count;
}
// function pointer
{
void (*fp)(int, int) = f_void_2;
std::function<void (int, int)> r1(fp);
int i = 3;
int j = 4;
r1(i, j);
assert(count == save_count+7);
save_count = count;
}
// functor
{
A_void_2 a0;
std::function<void (int, int)> r1(a0);
int i = 4;
int j = 5;
r1(i, j);
assert(count == save_count+9);
save_count = count;
}
// member function pointer
{
void (A_void_2::*fp)(int) = &A_void_2::mem1;
std::function<void (A_void_2, int)> r1(fp);
A_void_2 a;
int i = 3;
r1(a, i);
assert(count == save_count+3);
save_count = count;
std::function<void (A_void_2*, int)> r2(fp);
A_void_2* ap = &a;
r2(ap, i);
assert(count == save_count+3);
save_count = count;
}
// const member function pointer
{
void (A_void_2::*fp)(int) const = &A_void_2::mem2;
std::function<void (A_void_2, int)> r1(fp);
A_void_2 a;
int i = 4;
r1(a, i);
assert(count == save_count+4);
save_count = count;
std::function<void (A_void_2*, int)> r2(fp);
A_void_2* ap = &a;
r2(ap, i);
assert(count == save_count+4);
save_count = count;
}
}
// 2 arg, return int
int f_int_2(int i, int j)
{
return i+j;
}
struct A_int_2
{
int operator()(int i, int j)
{
return i+j;
}
int mem1(int i) {return i+1;}
int mem2(int i) const {return i+2;}
};
void
testint_2()
{
// function
{
std::function<int (int, int)> r1(f_int_2);
int i = 2;
int j = 3;
assert(r1(i, j) == i+j);
}
// function pointer
{
int (*fp)(int, int) = f_int_2;
std::function<int (int, int)> r1(fp);
int i = 3;
int j = 4;
assert(r1(i, j) == i+j);
}
// functor
{
A_int_2 a0;
std::function<int (int, int)> r1(a0);
int i = 4;
int j = 5;
assert(r1(i, j) == i+j);
}
// member function pointer
{
int(A_int_2::*fp)(int) = &A_int_2::mem1;
std::function<int (A_int_2, int)> r1(fp);
A_int_2 a;
int i = 3;
assert(r1(a, i) == i+1);
std::function<int (A_int_2*, int)> r2(fp);
A_int_2* ap = &a;
assert(r2(ap, i) == i+1);
}
// const member function pointer
{
int (A_int_2::*fp)(int) const = &A_int_2::mem2;
std::function<int (A_int_2, int)> r1(fp);
A_int_2 a;
int i = 4;
assert(r1(a, i) == i+2);
std::function<int (A_int_2*, int)> r2(fp);
A_int_2* ap = &a;
assert(r2(ap, i) == i+2);
}
}
int main()
{
test_void_1();
test_int_1();
test_void_2();
testint_2();
}
\ 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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {++count;}
};
void
test_void_1()
{
int save_count = count;
// function
{
std::function<void (int)> r1(f_void_1);
int i = 2;
r1(i);
assert(count == save_count+2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
std::function<void (int)> r1(fp);
int i = 3;
r1(i);
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
std::function<void (int)> r1(a0);
int i = 4;
r1(i);
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::function<void (A_void_1)> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
std::function<void (A_void_1*)> r2 = fp;
r2(ap);
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::function<void (A_void_1)> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
std::function<void (A_void_1*)> r2(fp);
A_void_1* ap = &a;
r2(ap);
assert(count == save_count+1);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
// function
{
std::function<int (int)> r1(f_int_1);
int i = 2;
assert(r1(i) == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
std::function<int (int)> r1(fp);
int i = 3;
assert(r1(i) == 4);
}
// functor
{
A_int_1 a0;
std::function<int (int)> r1(a0);
int i = 4;
assert(r1(i) == 3);
}
// member function pointer
{
int (A_int_1::*fp)() = &A_int_1::mem1;
std::function<int (A_int_1)> r1(fp);
A_int_1 a;
assert(r1(a) == 3);
std::function<int (A_int_1*)> r2(fp);
A_int_1* ap = &a;
assert(r2(ap) == 3);
}
// const member function pointer
{
int (A_int_1::*fp)() const = &A_int_1::mem2;
std::function<int (A_int_1)> r1(fp);
A_int_1 a;
assert(r1(a) == 4);
std::function<int (A_int_1*)> r2(fp);
A_int_1* ap = &a;
assert(r2(ap) == 4);
}
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
std::function<int& (A_int_1&)> r1(fp);
A_int_1 a;
assert(r1(a) == 5);
r1(a) = 6;
assert(r1(a) == 6);
std::function<int& (A_int_1*)> r2(fp);
A_int_1* ap = &a;
assert(r2(ap) == 6);
r2(ap) = 7;
assert(r2(ap) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
int save_count = count;
// function
{
std::function<void (int, int)> r1(f_void_2);
int i = 2;
int j = 3;
r1(i, j);
assert(count == save_count+5);
save_count = count;
}
// function pointer
{
void (*fp)(int, int) = f_void_2;
std::function<void (int, int)> r1(fp);
int i = 3;
int j = 4;
r1(i, j);
assert(count == save_count+7);
save_count = count;
}
// functor
{
A_void_2 a0;
std::function<void (int, int)> r1(a0);
int i = 4;
int j = 5;
r1(i, j);
assert(count == save_count+9);
save_count = count;
}
// member function pointer
{
void (A_void_2::*fp)(int) = &A_void_2::mem1;
std::function<void (A_void_2, int)> r1(fp);
A_void_2 a;
int i = 3;
r1(a, i);
assert(count == save_count+3);
save_count = count;
std::function<void (A_void_2*, int)> r2(fp);
A_void_2* ap = &a;
r2(ap, i);
assert(count == save_count+3);
save_count = count;
}
// const member function pointer
{
void (A_void_2::*fp)(int) const = &A_void_2::mem2;
std::function<void (A_void_2, int)> r1(fp);
A_void_2 a;
int i = 4;
r1(a, i);
assert(count == save_count+4);
save_count = count;
std::function<void (A_void_2*, int)> r2(fp);
A_void_2* ap = &a;
r2(ap, i);
assert(count == save_count+4);
save_count = count;
}
}
// 2 arg, return int
int f_int_2(int i, int j)
{
return i+j;
}
struct A_int_2
{
int operator()(int i, int j)
{
return i+j;
}
int mem1(int i) {return i+1;}
int mem2(int i) const {return i+2;}
};
void
testint_2()
{
// function
{
std::function<int (int, int)> r1(f_int_2);
int i = 2;
int j = 3;
assert(r1(i, j) == i+j);
}
// function pointer
{
int (*fp)(int, int) = f_int_2;
std::function<int (int, int)> r1(fp);
int i = 3;
int j = 4;
assert(r1(i, j) == i+j);
}
// functor
{
A_int_2 a0;
std::function<int (int, int)> r1(a0);
int i = 4;
int j = 5;
assert(r1(i, j) == i+j);
}
// member function pointer
{
int(A_int_2::*fp)(int) = &A_int_2::mem1;
std::function<int (A_int_2, int)> r1(fp);
A_int_2 a;
int i = 3;
assert(r1(a, i) == i+1);
std::function<int (A_int_2*, int)> r2(fp);
A_int_2* ap = &a;
assert(r2(ap, i) == i+1);
}
// const member function pointer
{
int (A_int_2::*fp)(int) const = &A_int_2::mem2;
std::function<int (A_int_2, int)> r1(fp);
A_int_2 a;
int i = 4;
assert(r1(a, i) == i+2);
std::function<int (A_int_2*, int)> r2(fp);
A_int_2* ap = &a;
assert(r2(ap, i) == i+2);
}
}
int main()
{
test_void_1();
test_int_1();
test_void_2();
testint_2();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp index 6bab12a9c..1f84b3c78 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <cassert>
// 0 args, return int
int count = 0;
int f_int_0()
{
return 3;
}
struct A_int_0
{
int operator()() {return 4;}
};
void
test_int_0()
{
// function
{
std::function<int ()> r1(f_int_0);
assert(r1() == 3);
}
// function pointer
{
int (*fp)() = f_int_0;
std::function<int ()> r1(fp);
assert(r1() == 3);
}
// functor
{
A_int_0 a0;
std::function<int ()> r1(a0);
assert(r1() == 4);
}
}
int main()
{
test_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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <cassert>
// 0 args, return int
int count = 0;
int f_int_0()
{
return 3;
}
struct A_int_0
{
int operator()() {return 4;}
};
void
test_int_0()
{
// function
{
std::function<int ()> r1(f_int_0);
assert(r1() == 3);
}
// function pointer
{
int (*fp)() = f_int_0;
std::function<int ()> r1(fp);
assert(r1() == 3);
}
// functor
{
A_int_0 a0;
std::function<int ()> r1(a0);
assert(r1() == 4);
}
}
int main()
{
test_int_0();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp index 5df26064f..d9f92d398 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
// 0 args, return void
int count = 0;
void f_void_0()
{
++count;
}
struct A_void_0
{
void operator()() {++count;}
};
void
test_void_0()
{
int save_count = count;
// function
{
std::function<void ()> r1(f_void_0);
r1();
assert(count == save_count+1);
save_count = count;
}
// function pointer
{
void (*fp)() = f_void_0;
std::function<void ()> r1(fp);
r1();
assert(count == save_count+1);
save_count = count;
}
// functor
{
A_void_0 a0;
std::function<void ()> r1(a0);
r1();
assert(count == save_count+1);
save_count = count;
}
}
int main()
{
test_void_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...)>
// R operator()(ArgTypes... args) const
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
// 0 args, return void
int count = 0;
void f_void_0()
{
++count;
}
struct A_void_0
{
void operator()() {++count;}
};
void
test_void_0()
{
int save_count = count;
// function
{
std::function<void ()> r1(f_void_0);
r1();
assert(count == save_count+1);
save_count = count;
}
// function pointer
{
void (*fp)() = f_void_0;
std::function<void ()> r1(fp);
r1();
assert(count == save_count+1);
save_count = count;
}
// functor
{
A_void_0 a0;
std::function<void ()> r1(a0);
r1();
assert(count == save_count+1);
save_count = count;
}
}
int main()
{
test_void_0();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp index bbb84aae4..eeb695601 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_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.mod/swap.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp index 1e19ee2aa..935bc839d 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.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...)>
// void swap(function& other);
#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;
explicit A(int j)
{
++count;
data_[0] = j;
}
A(const A& a)
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = a.data_[i];
}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int id() const {return data_[0];}
};
int A::count = 0;
int g(int) {return 0;}
int h(int) {return 1;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = A(2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 1);
assert(f2.target<A>()->id() == 2);
f1.swap(f2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 2);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = g;
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
f1.swap(f2);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = A(1);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
f1.swap(f2);
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = h;
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == g);
assert(*f2.target<int(*)(int)>() == h);
f1.swap(f2);
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == h);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 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...)>
// void swap(function& other);
#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;
explicit A(int j)
{
++count;
data_[0] = j;
}
A(const A& a)
{
++count;
for (int i = 0; i < 10; ++i)
data_[i] = a.data_[i];
}
~A() {--count;}
int operator()(int i) const
{
for (int j = 0; j < 10; ++j)
i += data_[j];
return i;
}
int id() const {return data_[0];}
};
int A::count = 0;
int g(int) {return 0;}
int h(int) {return 1;}
int main()
{
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = A(2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 1);
assert(f2.target<A>()->id() == 2);
f1.swap(f2);
assert(A::count == 2);
assert(new_called == 2);
assert(f1.target<A>()->id() == 2);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = g;
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
f1.swap(f2);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = A(1);
assert(A::count == 1);
assert(new_called == 1);
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
f1.swap(f2);
assert(A::count == 1);
assert(new_called == 1);
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 0);
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = h;
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == g);
assert(*f2.target<int(*)(int)>() == h);
f1.swap(f2);
assert(A::count == 0);
assert(new_called == 0);
assert(*f1.target<int(*)(int)>() == h);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
assert(new_called == 0);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp index 8a2ae86b7..6ea89d4c1 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.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 <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator==(const function<R(ArgTypes...)>&, nullptr_t);
//
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator==(nullptr_t, const function<R(ArgTypes...)>&);
//
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
//
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
#include <functional>
#include <cassert>
int g(int) {return 0;}
int main()
{
{
std::function<int(int)> f;
assert(f == nullptr);
assert(nullptr == f);
f = g;
assert(f != nullptr);
assert(nullptr != 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...)>
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator==(const function<R(ArgTypes...)>&, nullptr_t);
//
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator==(nullptr_t, const function<R(ArgTypes...)>&);
//
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
//
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
#include <functional>
#include <cassert>
int g(int) {return 0;}
int main()
{
{
std::function<int(int)> f;
assert(f == nullptr);
assert(nullptr == f);
f = g;
assert(f != nullptr);
assert(nullptr != f);
}
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp index 53fa50ba8..718aedcb2 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.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<typename T>
// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
// T*
// target();
// template<typename T>
// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
// const T*
// target() const;
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
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()
{
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
{
std::function<int(int)> f = g;
assert(A::count == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(A::count == 0);
{
const std::function<int(int)> f = A();
assert(A::count == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
{
const std::function<int(int)> f = g;
assert(A::count == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(A::count == 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<typename T>
// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
// T*
// target();
// template<typename T>
// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
// const T*
// target() const;
#include <functional>
#include <new>
#include <cstdlib>
#include <cassert>
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()
{
{
std::function<int(int)> f = A();
assert(A::count == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
{
std::function<int(int)> f = g;
assert(A::count == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(A::count == 0);
{
const std::function<int(int)> f = A();
assert(A::count == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
{
const std::function<int(int)> f = g;
assert(A::count == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
assert(A::count == 0);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp index 08abfadc3..36bd29fcf 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.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...)>
// const std::type_info& target_type() const;
#include <functional>
#include <typeinfo>
#include <cassert>
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()
{
{
std::function<int(int)> f = A();
assert(f.target_type() == typeid(A));
}
{
std::function<int(int)> f;
assert(f.target_type() == typeid(void));
}
}
\ 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...)>
// const std::type_info& target_type() const;
#include <functional>
#include <typeinfo>
#include <cassert>
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()
{
{
std::function<int(int)> f = A();
assert(f.target_type() == typeid(A));
}
{
std::function<int(int)> f;
assert(f.target_type() == typeid(void));
}
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp index 17a8794bd..819c8fd1b 100644 --- a/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp +++ b/test/utilities/function.objects/func.wrap/func.wrap.func/types.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>
// template<Returnable R, CopyConstructible... ArgTypes>
// class function<R(ArgTypes...)>
// : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
// // ArgTypes contains T1
// : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
// // ArgTypes contains T1 and T2
// {
// public:
// typedef R result_type;
// ...
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((!std::is_base_of<std::unary_function <int, int>,
std::function<int()> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, int>,
std::function<int()> >::value), "");
static_assert(( std::is_same< std::function<int()>::result_type,
int>::value), "");
static_assert(( std::is_base_of<std::unary_function <int, double>,
std::function<double(int)> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, double>,
std::function<double(int)> >::value), "");
static_assert(( std::is_same< std::function<double(int)>::result_type,
double>::value), "");
static_assert((!std::is_base_of<std::unary_function <int, double>,
std::function<double(int, char)> >::value), "");
static_assert(( std::is_base_of<std::binary_function<int, char, double>,
std::function<double(int, char)> >::value), "");
static_assert(( std::is_same< std::function<double(int, char)>::result_type,
double>::value), "");
}
\ 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>
// template<Returnable R, CopyConstructible... ArgTypes>
// class function<R(ArgTypes...)>
// : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
// // ArgTypes contains T1
// : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
// // ArgTypes contains T1 and T2
// {
// public:
// typedef R result_type;
// ...
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((!std::is_base_of<std::unary_function <int, int>,
std::function<int()> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, int>,
std::function<int()> >::value), "");
static_assert(( std::is_same< std::function<int()>::result_type,
int>::value), "");
static_assert(( std::is_base_of<std::unary_function <int, double>,
std::function<double(int)> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, double>,
std::function<double(int)> >::value), "");
static_assert(( std::is_same< std::function<double(int)>::result_type,
double>::value), "");
static_assert((!std::is_base_of<std::unary_function <int, double>,
std::function<double(int, char)> >::value), "");
static_assert(( std::is_base_of<std::binary_function<int, char, double>,
std::function<double(int, char)> >::value), "");
static_assert(( std::is_same< std::function<double(int, char)>::result_type,
double>::value), "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp b/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp index 923482612..e8db90cbe 100644 --- a/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp +++ b/test/utilities/function.objects/func.wrap/nothing_to_do.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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}
\ No newline at end of file diff --git a/test/utilities/function.objects/function.pointer.adaptors/pointer_to_binary_function.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_binary_function.pass.cpp index f3f2c0a72..0538c6ea3 100644 --- a/test/utilities/function.objects/function.pointer.adaptors/pointer_to_binary_function.pass.cpp +++ b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_binary_function.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>
// pointer_to_binary_function
#include <functional>
#include <type_traits>
#include <cassert>
double binary_f(int i, short j) {return i - j + .75;}
int main()
{
typedef std::pointer_to_binary_function<int, short, double> F;
static_assert((std::is_base_of<std::binary_function<int, short, double>, F>::value), "");
const F f(binary_f);
assert(f(36, 27) == 9.75);
}
\ 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>
// pointer_to_binary_function
#include <functional>
#include <type_traits>
#include <cassert>
double binary_f(int i, short j) {return i - j + .75;}
int main()
{
typedef std::pointer_to_binary_function<int, short, double> F;
static_assert((std::is_base_of<std::binary_function<int, short, double>, F>::value), "");
const F f(binary_f);
assert(f(36, 27) == 9.75);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/function.pointer.adaptors/pointer_to_unary_function.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_unary_function.pass.cpp index 70a9cebc9..9ff953e55 100644 --- a/test/utilities/function.objects/function.pointer.adaptors/pointer_to_unary_function.pass.cpp +++ b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_unary_function.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>
// pointer_to_unary_function
#include <functional>
#include <type_traits>
#include <cassert>
double unary_f(int i) {return 0.5 - i;}
int main()
{
typedef std::pointer_to_unary_function<int, double> F;
static_assert((std::is_base_of<std::unary_function<int, double>, F>::value), "");
const F f(unary_f);
assert(f(36) == -35.5);
}
\ 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>
// pointer_to_unary_function
#include <functional>
#include <type_traits>
#include <cassert>
double unary_f(int i) {return 0.5 - i;}
int main()
{
typedef std::pointer_to_unary_function<int, double> F;
static_assert((std::is_base_of<std::unary_function<int, double>, F>::value), "");
const F f(unary_f);
assert(f(36) == -35.5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/function.pointer.adaptors/ptr_fun1.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun1.pass.cpp index 4f377ef17..a4f16d0a8 100644 --- a/test/utilities/function.objects/function.pointer.adaptors/ptr_fun1.pass.cpp +++ b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun1.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>
// template <CopyConstructible Arg, Returnable Result>
// pointer_to_unary_function<Arg, Result>
// ptr_fun(Result (*f)(Arg));
#include <functional>
#include <type_traits>
#include <cassert>
double unary_f(int i) {return 0.5 - i;}
int main()
{
assert(std::ptr_fun(unary_f)(36) == -35.5);
}
\ 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>
// template <CopyConstructible Arg, Returnable Result>
// pointer_to_unary_function<Arg, Result>
// ptr_fun(Result (*f)(Arg));
#include <functional>
#include <type_traits>
#include <cassert>
double unary_f(int i) {return 0.5 - i;}
int main()
{
assert(std::ptr_fun(unary_f)(36) == -35.5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/function.pointer.adaptors/ptr_fun2.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun2.pass.cpp index 93c6376ef..846223209 100644 --- a/test/utilities/function.objects/function.pointer.adaptors/ptr_fun2.pass.cpp +++ b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun2.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>
// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result>
// pointer_to_binary_function<Arg1,Arg2,Result>
// ptr_fun(Result (*f)(Arg1, Arg2));
#include <functional>
#include <type_traits>
#include <cassert>
double binary_f(int i, short j) {return i - j + .75;}
int main()
{
assert(std::ptr_fun(binary_f)(36, 27) == 9.75);
}
\ 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>
// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result>
// pointer_to_binary_function<Arg1,Arg2,Result>
// ptr_fun(Result (*f)(Arg1, Arg2));
#include <functional>
#include <type_traits>
#include <cassert>
double binary_f(int i, short j) {return i - j + .75;}
int main()
{
assert(std::ptr_fun(binary_f)(36, 27) == 9.75);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/logical.operations/logical_and.pass.cpp b/test/utilities/function.objects/logical.operations/logical_and.pass.cpp index e193c90a6..ae03d2c74 100644 --- a/test/utilities/function.objects/logical.operations/logical_and.pass.cpp +++ b/test/utilities/function.objects/logical.operations/logical_and.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>
// logical_and
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::logical_and<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(!f(36, 0));
assert(!f(0, 36));
assert(!f(0, 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>
// logical_and
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::logical_and<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(!f(36, 0));
assert(!f(0, 36));
assert(!f(0, 0));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/logical.operations/logical_not.pass.cpp b/test/utilities/function.objects/logical.operations/logical_not.pass.cpp index 16bb419b5..471b145aa 100644 --- a/test/utilities/function.objects/logical.operations/logical_not.pass.cpp +++ b/test/utilities/function.objects/logical.operations/logical_not.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>
// logical_not
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::logical_not<int> F;
const F f = F();
static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
assert(!f(36));
assert(f(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>
// logical_not
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::logical_not<int> F;
const F f = F();
static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
assert(!f(36));
assert(f(0));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/logical.operations/logical_or.pass.cpp b/test/utilities/function.objects/logical.operations/logical_or.pass.cpp index 0f2518acf..35c1f815b 100644 --- a/test/utilities/function.objects/logical.operations/logical_or.pass.cpp +++ b/test/utilities/function.objects/logical.operations/logical_or.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>
// logical_or
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::logical_or<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(f(36, 0));
assert(f(0, 36));
assert(!f(0, 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>
// logical_or
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::logical_or<int> F;
const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(f(36, 36));
assert(f(36, 0));
assert(f(0, 36));
assert(!f(0, 0));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun.pass.cpp index b206b0001..7c1fb7432 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun.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>
// template<cReturnable S, ClassType T>
// const_mem_fun_t<S,T>
// mem_fun(S (T::*f)() const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun(&A::a3)(&a) == 1);
}
\ 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>
// template<cReturnable S, ClassType T>
// const_mem_fun_t<S,T>
// mem_fun(S (T::*f)() const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun(&A::a3)(&a) == 1);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1.pass.cpp index c2d6407cf..b23389abb 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1.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>
// template<Returnable S, ClassType T, CopyConstructible A>
// const_mem_fun1_t<S,T,A>
// mem_fun(S (T::*f)(A) const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun(&A::a4)(&a, 6) == 5);
}
\ 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>
// template<Returnable S, ClassType T, CopyConstructible A>
// const_mem_fun1_t<S,T,A>
// mem_fun(S (T::*f)(A) const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun(&A::a4)(&a, 6) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp index 933842e28..a7b5d50c2 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_ref_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>
// const_mem_fun1_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun1_ref_t<double, A, unsigned> F;
static_assert((std::is_base_of<std::binary_function<A, unsigned, double>, F>::value), "");
const F f(&A::a4);
const A a = A();
assert(f(a, 6) == 5);
}
\ 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>
// const_mem_fun1_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun1_ref_t<double, A, unsigned> F;
static_assert((std::is_base_of<std::binary_function<A, unsigned, double>, F>::value), "");
const F f(&A::a4);
const A a = A();
assert(f(a, 6) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_t.pass.cpp index 807181098..8989ae778 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_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>
// const_mem_fun1_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun1_t<double, A, unsigned> F;
static_assert((std::is_base_of<std::binary_function<const A*, unsigned, double>, F>::value), "");
const F f(&A::a4);
const A a = A();
assert(f(&a, 6) == 5);
}
\ 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>
// const_mem_fun1_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun1_t<double, A, unsigned> F;
static_assert((std::is_base_of<std::binary_function<const A*, unsigned, double>, F>::value), "");
const F f(&A::a4);
const A a = A();
assert(f(&a, 6) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref.pass.cpp index d8c3dbb01..987b4c72f 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref.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>
// template<Returnable S, ClassType T>
// const_mem_fun_ref_t<S,T>
// mem_fun_ref(S (T::*f)() const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun_ref(&A::a3)(a) == 1);
}
\ 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>
// template<Returnable S, ClassType T>
// const_mem_fun_ref_t<S,T>
// mem_fun_ref(S (T::*f)() const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun_ref(&A::a3)(a) == 1);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref1.pass.cpp index 5cba2c9b0..60aadc799 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref1.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref1.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>
// template<Returnable S, ClassType T, CopyConstructible A>
// const_mem_fun1_ref_t<S,T,A>
// mem_fun_ref(S (T::*f)(A) const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun_ref(&A::a4)(a, 6) == 5);
}
\ 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>
// template<Returnable S, ClassType T, CopyConstructible A>
// const_mem_fun1_ref_t<S,T,A>
// mem_fun_ref(S (T::*f)(A) const);
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
const A a = A();
assert(std::mem_fun_ref(&A::a4)(a, 6) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp index f28a36af9..424622ed3 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref_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>
// const_mem_fun_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun_ref_t<int, A> F;
static_assert((std::is_base_of<std::unary_function<A, int>, F>::value), "");
const F f(&A::a3);
const A a = A();
assert(f(a) == 1);
}
\ 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>
// const_mem_fun_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun_ref_t<int, A> F;
static_assert((std::is_base_of<std::unary_function<A, int>, F>::value), "");
const F f(&A::a3);
const A a = A();
assert(f(a) == 1);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_t.pass.cpp index fdcd440c0..6eebb0edb 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_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>
// const_mem_fun_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun_t<int, A> F;
static_assert((std::is_base_of<std::unary_function<const A*, int>, F>::value), "");
const F f(&A::a3);
const A a = A();
assert(f(&a) == 1);
}
\ 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>
// const_mem_fun_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::const_mem_fun_t<int, A> F;
static_assert((std::is_base_of<std::unary_function<const A*, int>, F>::value), "");
const F f(&A::a3);
const A a = A();
assert(f(&a) == 1);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun.pass.cpp index 0ea08e8d8..144691bf8 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun.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>
// template<Returnable S, ClassType T>
// mem_fun_t<S,T>
// mem_fun(S (T::*f)());
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun(&A::a1)(&a) == 5);
}
\ 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>
// template<Returnable S, ClassType T>
// mem_fun_t<S,T>
// mem_fun(S (T::*f)());
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun(&A::a1)(&a) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1.pass.cpp index e47fb6cc6..514fac930 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1.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>
// template<Returnable S, ClassType T, CopyConstructible A>
// mem_fun1_t<S,T,A>
// mem_fun(S (T::*f)(A));
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun(&A::a2)(&a, 5) == 6);
}
\ 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>
// template<Returnable S, ClassType T, CopyConstructible A>
// mem_fun1_t<S,T,A>
// mem_fun(S (T::*f)(A));
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun(&A::a2)(&a, 5) == 6);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_ref_t.pass.cpp index adc00597c..b451d680b 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_ref_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_ref_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>
// mem_fun1_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun1_ref_t<short, A, int> F;
static_assert((std::is_base_of<std::binary_function<A, int, short>, F>::value), "");
const F f(&A::a2);
A a;
assert(f(a, 5) == 6);
}
\ 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>
// mem_fun1_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun1_ref_t<short, A, int> F;
static_assert((std::is_base_of<std::binary_function<A, int, short>, F>::value), "");
const F f(&A::a2);
A a;
assert(f(a, 5) == 6);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_t.pass.cpp index ab29d9a67..a9a62e050 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_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>
// mem_fun1_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun1_t<short, A, int> F;
static_assert((std::is_base_of<std::binary_function<A*, int, short>, F>::value), "");
const F f(&A::a2);
A a;
assert(f(&a, 5) == 6);
}
\ 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>
// mem_fun1_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun1_t<short, A, int> F;
static_assert((std::is_base_of<std::binary_function<A*, int, short>, F>::value), "");
const F f(&A::a2);
A a;
assert(f(&a, 5) == 6);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref.pass.cpp index 8d79e7ac7..785305eaa 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref.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>
// template<Returnable S, ClassType T>
// mem_fun_ref_t<S,T>
// mem_fun_ref(S (T::*f)());
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun_ref(&A::a1)(a) == 5);
}
\ 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>
// template<Returnable S, ClassType T>
// mem_fun_ref_t<S,T>
// mem_fun_ref(S (T::*f)());
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun_ref(&A::a1)(a) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref1.pass.cpp index bbc64a14b..733db16ee 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref1.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref1.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>
// template<Returnable S, ClassType T, CopyConstructible A>
// mem_fun1_ref_t<S,T,A>
// mem_fun_ref(S (T::*f)(A));
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun_ref(&A::a2)(a, 5) == 6);
}
\ 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>
// template<Returnable S, ClassType T, CopyConstructible A>
// mem_fun1_ref_t<S,T,A>
// mem_fun_ref(S (T::*f)(A));
#include <functional>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
A a;
assert(std::mem_fun_ref(&A::a2)(a, 5) == 6);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref_t.pass.cpp index 9a9e9dd71..d92f378f6 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref_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>
// mem_fun_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun_ref_t<char, A> F;
static_assert((std::is_base_of<std::unary_function<A, char>, F>::value), "");
const F f(&A::a1);
A a;
assert(f(a) == 5);
}
\ 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>
// mem_fun_ref_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun_ref_t<char, A> F;
static_assert((std::is_base_of<std::unary_function<A, char>, F>::value), "");
const F f(&A::a1);
A a;
assert(f(a) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_t.pass.cpp index 5db73e169..721e9266d 100644 --- a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_t.pass.cpp +++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_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>
// mem_fun_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun_t<char, A> F;
static_assert((std::is_base_of<std::unary_function<A*, char>, F>::value), "");
const F f(&A::a1);
A a;
assert(f(&a) == 5);
}
\ 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>
// mem_fun_t
#include <functional>
#include <type_traits>
#include <cassert>
struct A
{
char a1() {return 5;}
short a2(int i) {return short(i+1);}
int a3() const {return 1;}
double a4(unsigned i) const {return i-1;}
};
int main()
{
typedef std::mem_fun_t<char, A> F;
static_assert((std::is_base_of<std::unary_function<A*, char>, F>::value), "");
const F f(&A::a1);
A a;
assert(f(&a) == 5);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/negators/binary_negate.pass.cpp b/test/utilities/function.objects/negators/binary_negate.pass.cpp index 25f791448..da48bbd4f 100644 --- a/test/utilities/function.objects/negators/binary_negate.pass.cpp +++ b/test/utilities/function.objects/negators/binary_negate.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>
// binary_negate
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::binary_negate<std::logical_and<int> > F;
const F f = F(std::logical_and<int>());
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert( f(36, 0));
assert( f(0, 36));
assert( f(0, 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>
// binary_negate
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::binary_negate<std::logical_and<int> > F;
const F f = F(std::logical_and<int>());
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
assert(!f(36, 36));
assert( f(36, 0));
assert( f(0, 36));
assert( f(0, 0));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/negators/not1.pass.cpp b/test/utilities/function.objects/negators/not1.pass.cpp index 03bb7a7c9..6b399307e 100644 --- a/test/utilities/function.objects/negators/not1.pass.cpp +++ b/test/utilities/function.objects/negators/not1.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>
// not1
#include <functional>
#include <cassert>
int main()
{
typedef std::logical_not<int> F;
assert(std::not1(F())(36));
assert(!std::not1(F())(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>
// not1
#include <functional>
#include <cassert>
int main()
{
typedef std::logical_not<int> F;
assert(std::not1(F())(36));
assert(!std::not1(F())(0));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/negators/not2.pass.cpp b/test/utilities/function.objects/negators/not2.pass.cpp index 1f32fb100..9e65415cb 100644 --- a/test/utilities/function.objects/negators/not2.pass.cpp +++ b/test/utilities/function.objects/negators/not2.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>
// not2
#include <functional>
#include <cassert>
int main()
{
typedef std::logical_and<int> F;
assert(!std::not2(F())(36, 36));
assert( std::not2(F())(36, 0));
assert( std::not2(F())(0, 36));
assert( std::not2(F())(0, 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>
// not2
#include <functional>
#include <cassert>
int main()
{
typedef std::logical_and<int> F;
assert(!std::not2(F())(36, 36));
assert( std::not2(F())(36, 0));
assert( std::not2(F())(0, 36));
assert( std::not2(F())(0, 0));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/negators/unary_negate.pass.cpp b/test/utilities/function.objects/negators/unary_negate.pass.cpp index 55696b861..9c5c2592b 100644 --- a/test/utilities/function.objects/negators/unary_negate.pass.cpp +++ b/test/utilities/function.objects/negators/unary_negate.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>
// unary_negate
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::unary_negate<std::logical_not<int> > F;
const F f = F(std::logical_not<int>());
static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
assert(f(36));
assert(!f(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>
// unary_negate
#include <functional>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::unary_negate<std::logical_not<int> > F;
const F f = F(std::logical_not<int>());
static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
assert(f(36));
assert(!f(0));
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/binary.pass.cpp b/test/utilities/function.objects/refwrap/binary.pass.cpp index 3dfae3e73..e9d7dda00 100644 --- a/test/utilities/function.objects/refwrap/binary.pass.cpp +++ b/test/utilities/function.objects/refwrap/binary.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>
// reference_wrapper
// check for deriving from binary_function
#include <functional>
#include <type_traits>
class functor1
: public std::unary_function<int, char>
{
};
class functor2
: public std::binary_function<char, int, double>
{
};
class functor3
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
typedef float result_type;
};
class functor4
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
};
struct C
{
typedef int argument_type;
typedef int result_type;
};
int main()
{
static_assert((!std::is_base_of<std::binary_function<int, char, int>,
std::reference_wrapper<functor1> >::value), "");
static_assert((std::is_base_of<std::binary_function<char, int, double>,
std::reference_wrapper<functor2> >::value), "");
static_assert((std::is_base_of<std::binary_function<char, int, double>,
std::reference_wrapper<functor3> >::value), "");
static_assert((std::is_base_of<std::binary_function<char, int, double>,
std::reference_wrapper<functor4> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, int>,
std::reference_wrapper<C> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float ()> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float (int)> >::value), "");
static_assert((std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float (int, int)> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float(*)()> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float(*)(int)> >::value), "");
static_assert((std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float(*)(int, int)> >::value), "");
static_assert((!std::is_base_of<std::binary_function<C*, int, float>,
std::reference_wrapper<float(C::*)()> >::value), "");
static_assert((std::is_base_of<std::binary_function<C*, int, float>,
std::reference_wrapper<float(C::*)(int)> >::value), "");
static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
std::reference_wrapper<float(C::*)(int) const volatile> >::value), "");
}
\ 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>
// reference_wrapper
// check for deriving from binary_function
#include <functional>
#include <type_traits>
class functor1
: public std::unary_function<int, char>
{
};
class functor2
: public std::binary_function<char, int, double>
{
};
class functor3
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
typedef float result_type;
};
class functor4
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
};
struct C
{
typedef int argument_type;
typedef int result_type;
};
int main()
{
static_assert((!std::is_base_of<std::binary_function<int, char, int>,
std::reference_wrapper<functor1> >::value), "");
static_assert((std::is_base_of<std::binary_function<char, int, double>,
std::reference_wrapper<functor2> >::value), "");
static_assert((std::is_base_of<std::binary_function<char, int, double>,
std::reference_wrapper<functor3> >::value), "");
static_assert((std::is_base_of<std::binary_function<char, int, double>,
std::reference_wrapper<functor4> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, int>,
std::reference_wrapper<C> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float ()> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float (int)> >::value), "");
static_assert((std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float (int, int)> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float(*)()> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float(*)(int)> >::value), "");
static_assert((std::is_base_of<std::binary_function<int, int, float>,
std::reference_wrapper<float(*)(int, int)> >::value), "");
static_assert((!std::is_base_of<std::binary_function<C*, int, float>,
std::reference_wrapper<float(C::*)()> >::value), "");
static_assert((std::is_base_of<std::binary_function<C*, int, float>,
std::reference_wrapper<float(C::*)(int)> >::value), "");
static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
std::reference_wrapper<float(C::*)(int) const volatile> >::value), "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp index c7bb7a0c7..76986162b 100644 --- a/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.access/conversion.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>
// reference_wrapper
// operator T& () const;
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
T& r2 = r;
assert(&r2 == &t);
}
void f() {}
int main()
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ 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>
// reference_wrapper
// operator T& () const;
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
T& r2 = r;
assert(&r2 == &t);
}
void f() {}
int main()
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp index c49105778..bccafd746 100644 --- a/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.assign/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>
// reference_wrapper
// reference_wrapper& operator=(const reference_wrapper<T>& x);
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
T t2 = t;
std::reference_wrapper<T> r2(t2);
r2 = r;
assert(&r2.get() == &t);
}
void f() {}
void g() {}
void
test_function()
{
std::reference_wrapper<void ()> r(f);
std::reference_wrapper<void ()> r2(g);
r2 = r;
assert(&r2.get() == &f);
}
int main()
{
void (*fp)() = f;
test(fp);
test_function();
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ 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>
// reference_wrapper
// reference_wrapper& operator=(const reference_wrapper<T>& x);
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
T t2 = t;
std::reference_wrapper<T> r2(t2);
r2 = r;
assert(&r2.get() == &t);
}
void f() {}
void g() {}
void
test_function()
{
std::reference_wrapper<void ()> r(f);
std::reference_wrapper<void ()> r2(g);
r2 = r;
assert(&r2.get() == &f);
}
int main()
{
void (*fp)() = f;
test(fp);
test_function();
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp index a866a4120..8bdbec5a7 100644 --- a/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.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>
// reference_wrapper
// reference_wrapper(const reference_wrapper<T>& x);
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
std::reference_wrapper<T> r2 = r;
assert(&r2.get() == &t);
}
void f() {}
int main()
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ 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>
// reference_wrapper
// reference_wrapper(const reference_wrapper<T>& x);
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
std::reference_wrapper<T> r2 = r;
assert(&r2.get() == &t);
}
void f() {}
int main()
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp index 633725b5e..f07592db4 100644 --- a/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.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>
// reference_wrapper
// reference_wrapper(T&&) = delete;
#include <functional>
#include <cassert>
int main()
{
std::reference_wrapper<const int> r(3);
}
\ 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>
// reference_wrapper
// reference_wrapper(T&&) = delete;
#include <functional>
#include <cassert>
int main()
{
std::reference_wrapper<const int> r(3);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp index 5f1414006..a4c2c8727 100644 --- a/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.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>
// reference_wrapper
// reference_wrapper(T& t);
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
assert(&r.get() == &t);
}
void f() {}
int main()
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ 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>
// reference_wrapper
// reference_wrapper(T& t);
#include <functional>
#include <cassert>
class functor1
: public std::unary_function<int, char>
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
assert(&r.get() == &t);
}
void f() {}
int main()
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp index 7264e4fc3..f60de648d 100644 --- a/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<const T> cref(const T& t);
#include <functional>
#include <cassert>
int main()
{
int i = 0;
std::reference_wrapper<const int> r = std::cref(i);
assert(&r.get() == &i);
}
\ 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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<const T> cref(const T& t);
#include <functional>
#include <cassert>
int main()
{
int i = 0;
std::reference_wrapper<const int> r = std::cref(i);
assert(&r.get() == &i);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp index db712ceba..2f05d467e 100644 --- a/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<const T> cref(reference_wrapper<T> t);
#include <functional>
#include <cassert>
int main()
{
const int i = 0;
std::reference_wrapper<const int> r1 = std::cref(i);
std::reference_wrapper<const int> r2 = std::cref(r1);
assert(&r2.get() == &i);
}
\ 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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<const T> cref(reference_wrapper<T> t);
#include <functional>
#include <cassert>
int main()
{
const int i = 0;
std::reference_wrapper<const int> r1 = std::cref(i);
std::reference_wrapper<const int> r2 = std::cref(r1);
assert(&r2.get() == &i);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp index 934a9a8da..7fe32d7b0 100644 --- a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<T> ref(T& t);
// Don't allow binding to a temp
#include <functional>
struct A {};
const A source() {return A();}
int main()
{
std::reference_wrapper<const A> r = std::ref(source());
}
\ 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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<T> ref(T& t);
// Don't allow binding to a temp
#include <functional>
struct A {};
const A source() {return A();}
int main()
{
std::reference_wrapper<const A> r = std::ref(source());
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp index 684b1b358..d4e493e09 100644 --- a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<T> ref(T& t);
#include <functional>
#include <cassert>
int main()
{
int i = 0;
std::reference_wrapper<int> r = std::ref(i);
assert(&r.get() == &i);
}
\ 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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<T> ref(T& t);
#include <functional>
#include <cassert>
int main()
{
int i = 0;
std::reference_wrapper<int> r = std::ref(i);
assert(&r.get() == &i);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp index e8221665b..f486a00ae 100644 --- a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<T> ref(reference_wrapper<T>t);
#include <functional>
#include <cassert>
int main()
{
int i = 0;
std::reference_wrapper<int> r1 = std::ref(i);
std::reference_wrapper<int> r2 = std::ref(r1);
assert(&r2.get() == &i);
}
\ 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>
// reference_wrapper
// template <ObjectType T> reference_wrapper<T> ref(reference_wrapper<T>t);
#include <functional>
#include <cassert>
int main()
{
int i = 0;
std::reference_wrapper<int> r1 = std::ref(i);
std::reference_wrapper<int> r2 = std::ref(r1);
assert(&r2.get() == &i);
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp index 99a7fe2dd..d7b94ab60 100644 --- a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
// member data pointer: cv qualifiers should transfer from argument to return type
struct A_int_1
{
A_int_1() : data_(5) {}
int data_;
};
void
test_int_1()
{
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
std::reference_wrapper<int A_int_1::*> r1(fp);
A_int_1 a;
assert(r1(a) == 5);
r1(a) = 6;
assert(r1(a) == 6);
const A_int_1* ap = &a;
assert(r1(ap) == 6);
r1(ap) = 7;
assert(r1(ap) == 7);
}
}
int main()
{
test_int_1();
}
\ 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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
// member data pointer: cv qualifiers should transfer from argument to return type
struct A_int_1
{
A_int_1() : data_(5) {}
int data_;
};
void
test_int_1()
{
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
std::reference_wrapper<int A_int_1::*> r1(fp);
A_int_1 a;
assert(r1(a) == 5);
r1(a) = 6;
assert(r1(a) == 6);
const A_int_1* ap = &a;
assert(r1(ap) == 6);
r1(ap) = 7;
assert(r1(ap) == 7);
}
}
int main()
{
test_int_1();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp index 79a90b203..ca7f226b6 100644 --- a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {++count;}
};
void
test_void_1()
{
int save_count = count;
// function
{
std::reference_wrapper<void (int)> r1(f_void_1);
int i = 2;
r1(i);
assert(count == save_count+2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
std::reference_wrapper<void (*)(int)> r1(fp);
int i = 3;
r1(i);
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
std::reference_wrapper<A_void_1> r1(a0);
int i = 4;
r1(i);
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::reference_wrapper<void (A_void_1::*)()> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
r1(ap);
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::reference_wrapper<void (A_void_1::*)() const> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
r1(ap);
assert(count == save_count+1);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
// function
{
std::reference_wrapper<int (int)> r1(f_int_1);
int i = 2;
assert(r1(i) == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
std::reference_wrapper<int (*)(int)> r1(fp);
int i = 3;
assert(r1(i) == 4);
}
// functor
{
A_int_1 a0;
std::reference_wrapper<A_int_1> r1(a0);
int i = 4;
assert(r1(i) == 3);
}
// member function pointer
{
int (A_int_1::*fp)() = &A_int_1::mem1;
std::reference_wrapper<int (A_int_1::*)()> r1(fp);
A_int_1 a;
assert(r1(a) == 3);
A_int_1* ap = &a;
assert(r1(ap) == 3);
}
// const member function pointer
{
int (A_int_1::*fp)() const = &A_int_1::mem2;
std::reference_wrapper<int (A_int_1::*)() const> r1(fp);
A_int_1 a;
assert(r1(a) == 4);
A_int_1* ap = &a;
assert(r1(ap) == 4);
}
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
std::reference_wrapper<int A_int_1::*> r1(fp);
A_int_1 a;
assert(r1(a) == 5);
r1(a) = 6;
assert(r1(a) == 6);
A_int_1* ap = &a;
assert(r1(ap) == 6);
r1(ap) = 7;
assert(r1(ap) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
int save_count = count;
// function
{
std::reference_wrapper<void (int, int)> r1(f_void_2);
int i = 2;
int j = 3;
r1(i, j);
assert(count == save_count+5);
save_count = count;
}
// function pointer
{
void (*fp)(int, int) = f_void_2;
std::reference_wrapper<void (*)(int, int)> r1(fp);
int i = 3;
int j = 4;
r1(i, j);
assert(count == save_count+7);
save_count = count;
}
// functor
{
A_void_2 a0;
std::reference_wrapper<A_void_2> r1(a0);
int i = 4;
int j = 5;
r1(i, j);
assert(count == save_count+9);
save_count = count;
}
// member function pointer
{
void (A_void_2::*fp)(int) = &A_void_2::mem1;
std::reference_wrapper<void (A_void_2::*)(int)> r1(fp);
A_void_2 a;
int i = 3;
r1(a, i);
assert(count == save_count+3);
save_count = count;
A_void_2* ap = &a;
r1(ap, i);
assert(count == save_count+3);
save_count = count;
}
// const member function pointer
{
void (A_void_2::*fp)(int) const = &A_void_2::mem2;
std::reference_wrapper<void (A_void_2::*)(int) const> r1(fp);
A_void_2 a;
int i = 4;
r1(a, i);
assert(count == save_count+4);
save_count = count;
A_void_2* ap = &a;
r1(ap, i);
assert(count == save_count+4);
save_count = count;
}
}
// 2 arg, return int
int f_int_2(int i, int j)
{
return i+j;
}
struct A_int_2
{
int operator()(int i, int j)
{
return i+j;
}
int mem1(int i) {return i+1;}
int mem2(int i) const {return i+2;}
};
void
testint_2()
{
// function
{
std::reference_wrapper<int (int, int)> r1(f_int_2);
int i = 2;
int j = 3;
assert(r1(i, j) == i+j);
}
// function pointer
{
int (*fp)(int, int) = f_int_2;
std::reference_wrapper<int (*)(int, int)> r1(fp);
int i = 3;
int j = 4;
assert(r1(i, j) == i+j);
}
// functor
{
A_int_2 a0;
std::reference_wrapper<A_int_2> r1(a0);
int i = 4;
int j = 5;
assert(r1(i, j) == i+j);
}
// member function pointer
{
int(A_int_2::*fp)(int) = &A_int_2::mem1;
std::reference_wrapper<int (A_int_2::*)(int)> r1(fp);
A_int_2 a;
int i = 3;
assert(r1(a, i) == i+1);
A_int_2* ap = &a;
assert(r1(ap, i) == i+1);
}
// const member function pointer
{
int (A_int_2::*fp)(int) const = &A_int_2::mem2;
std::reference_wrapper<int (A_int_2::*)(int) const> r1(fp);
A_int_2 a;
int i = 4;
assert(r1(a, i) == i+2);
A_int_2* ap = &a;
assert(r1(ap, i) == i+2);
}
}
int main()
{
test_void_1();
test_int_1();
test_void_2();
testint_2();
}
\ 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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
int count = 0;
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
void mem1() {++count;}
void mem2() const {++count;}
};
void
test_void_1()
{
int save_count = count;
// function
{
std::reference_wrapper<void (int)> r1(f_void_1);
int i = 2;
r1(i);
assert(count == save_count+2);
save_count = count;
}
// function pointer
{
void (*fp)(int) = f_void_1;
std::reference_wrapper<void (*)(int)> r1(fp);
int i = 3;
r1(i);
assert(count == save_count+3);
save_count = count;
}
// functor
{
A_void_1 a0;
std::reference_wrapper<A_void_1> r1(a0);
int i = 4;
r1(i);
assert(count == save_count+4);
save_count = count;
}
// member function pointer
{
void (A_void_1::*fp)() = &A_void_1::mem1;
std::reference_wrapper<void (A_void_1::*)()> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
r1(ap);
assert(count == save_count+1);
save_count = count;
}
// const member function pointer
{
void (A_void_1::*fp)() const = &A_void_1::mem2;
std::reference_wrapper<void (A_void_1::*)() const> r1(fp);
A_void_1 a;
r1(a);
assert(count == save_count+1);
save_count = count;
A_void_1* ap = &a;
r1(ap);
assert(count == save_count+1);
save_count = count;
}
}
// 1 arg, return int
int f_int_1(int i)
{
return i + 1;
}
struct A_int_1
{
A_int_1() : data_(5) {}
int operator()(int i)
{
return i - 1;
}
int mem1() {return 3;}
int mem2() const {return 4;}
int data_;
};
void
test_int_1()
{
// function
{
std::reference_wrapper<int (int)> r1(f_int_1);
int i = 2;
assert(r1(i) == 3);
}
// function pointer
{
int (*fp)(int) = f_int_1;
std::reference_wrapper<int (*)(int)> r1(fp);
int i = 3;
assert(r1(i) == 4);
}
// functor
{
A_int_1 a0;
std::reference_wrapper<A_int_1> r1(a0);
int i = 4;
assert(r1(i) == 3);
}
// member function pointer
{
int (A_int_1::*fp)() = &A_int_1::mem1;
std::reference_wrapper<int (A_int_1::*)()> r1(fp);
A_int_1 a;
assert(r1(a) == 3);
A_int_1* ap = &a;
assert(r1(ap) == 3);
}
// const member function pointer
{
int (A_int_1::*fp)() const = &A_int_1::mem2;
std::reference_wrapper<int (A_int_1::*)() const> r1(fp);
A_int_1 a;
assert(r1(a) == 4);
A_int_1* ap = &a;
assert(r1(ap) == 4);
}
// member data pointer
{
int A_int_1::*fp = &A_int_1::data_;
std::reference_wrapper<int A_int_1::*> r1(fp);
A_int_1 a;
assert(r1(a) == 5);
r1(a) = 6;
assert(r1(a) == 6);
A_int_1* ap = &a;
assert(r1(ap) == 6);
r1(ap) = 7;
assert(r1(ap) == 7);
}
}
// 2 arg, return void
void f_void_2(int i, int j)
{
count += i+j;
}
struct A_void_2
{
void operator()(int i, int j)
{
count += i+j;
}
void mem1(int i) {count += i;}
void mem2(int i) const {count += i;}
};
void
test_void_2()
{
int save_count = count;
// function
{
std::reference_wrapper<void (int, int)> r1(f_void_2);
int i = 2;
int j = 3;
r1(i, j);
assert(count == save_count+5);
save_count = count;
}
// function pointer
{
void (*fp)(int, int) = f_void_2;
std::reference_wrapper<void (*)(int, int)> r1(fp);
int i = 3;
int j = 4;
r1(i, j);
assert(count == save_count+7);
save_count = count;
}
// functor
{
A_void_2 a0;
std::reference_wrapper<A_void_2> r1(a0);
int i = 4;
int j = 5;
r1(i, j);
assert(count == save_count+9);
save_count = count;
}
// member function pointer
{
void (A_void_2::*fp)(int) = &A_void_2::mem1;
std::reference_wrapper<void (A_void_2::*)(int)> r1(fp);
A_void_2 a;
int i = 3;
r1(a, i);
assert(count == save_count+3);
save_count = count;
A_void_2* ap = &a;
r1(ap, i);
assert(count == save_count+3);
save_count = count;
}
// const member function pointer
{
void (A_void_2::*fp)(int) const = &A_void_2::mem2;
std::reference_wrapper<void (A_void_2::*)(int) const> r1(fp);
A_void_2 a;
int i = 4;
r1(a, i);
assert(count == save_count+4);
save_count = count;
A_void_2* ap = &a;
r1(ap, i);
assert(count == save_count+4);
save_count = count;
}
}
// 2 arg, return int
int f_int_2(int i, int j)
{
return i+j;
}
struct A_int_2
{
int operator()(int i, int j)
{
return i+j;
}
int mem1(int i) {return i+1;}
int mem2(int i) const {return i+2;}
};
void
testint_2()
{
// function
{
std::reference_wrapper<int (int, int)> r1(f_int_2);
int i = 2;
int j = 3;
assert(r1(i, j) == i+j);
}
// function pointer
{
int (*fp)(int, int) = f_int_2;
std::reference_wrapper<int (*)(int, int)> r1(fp);
int i = 3;
int j = 4;
assert(r1(i, j) == i+j);
}
// functor
{
A_int_2 a0;
std::reference_wrapper<A_int_2> r1(a0);
int i = 4;
int j = 5;
assert(r1(i, j) == i+j);
}
// member function pointer
{
int(A_int_2::*fp)(int) = &A_int_2::mem1;
std::reference_wrapper<int (A_int_2::*)(int)> r1(fp);
A_int_2 a;
int i = 3;
assert(r1(a, i) == i+1);
A_int_2* ap = &a;
assert(r1(ap, i) == i+1);
}
// const member function pointer
{
int (A_int_2::*fp)(int) const = &A_int_2::mem2;
std::reference_wrapper<int (A_int_2::*)(int) const> r1(fp);
A_int_2 a;
int i = 4;
assert(r1(a, i) == i+2);
A_int_2* ap = &a;
assert(r1(ap, i) == i+2);
}
}
int main()
{
test_void_1();
test_int_1();
test_void_2();
testint_2();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp index 283177b9a..2bef95e6d 100644 --- a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
// 0 args, return int
int count = 0;
int f_int_0()
{
return 3;
}
struct A_int_0
{
int operator()() {return 4;}
};
void
test_int_0()
{
// function
{
std::reference_wrapper<int ()> r1(f_int_0);
assert(r1() == 3);
}
// function pointer
{
int (*fp)() = f_int_0;
std::reference_wrapper<int (*)()> r1(fp);
assert(r1() == 3);
}
// functor
{
A_int_0 a0;
std::reference_wrapper<A_int_0> r1(a0);
assert(r1() == 4);
}
}
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
};
int main()
{
test_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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
// 0 args, return int
int count = 0;
int f_int_0()
{
return 3;
}
struct A_int_0
{
int operator()() {return 4;}
};
void
test_int_0()
{
// function
{
std::reference_wrapper<int ()> r1(f_int_0);
assert(r1() == 3);
}
// function pointer
{
int (*fp)() = f_int_0;
std::reference_wrapper<int (*)()> r1(fp);
assert(r1() == 3);
}
// functor
{
A_int_0 a0;
std::reference_wrapper<A_int_0> r1(a0);
assert(r1() == 4);
}
}
// 1 arg, return void
void f_void_1(int i)
{
count += i;
}
struct A_void_1
{
void operator()(int i)
{
count += i;
}
};
int main()
{
test_int_0();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp index 649c5c0bb..e7445217c 100644 --- a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp +++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
// 0 args, return void
int count = 0;
void f_void_0()
{
++count;
}
struct A_void_0
{
void operator()() {++count;}
};
void
test_void_0()
{
int save_count = count;
// function
{
std::reference_wrapper<void ()> r1(f_void_0);
r1();
assert(count == save_count+1);
save_count = count;
}
// function pointer
{
void (*fp)() = f_void_0;
std::reference_wrapper<void (*)()> r1(fp);
r1();
assert(count == save_count+1);
save_count = count;
}
// functor
{
A_void_0 a0;
std::reference_wrapper<A_void_0> r1(a0);
r1();
assert(count == save_count+1);
save_count = count;
}
}
int main()
{
test_void_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>
// reference_wrapper
// template <class... ArgTypes>
// requires Callable<T, ArgTypes&&...>
// Callable<T, ArgTypes&&...>::result_type
// operator()(ArgTypes&&... args) const;
#include <functional>
#include <cassert>
// 0 args, return void
int count = 0;
void f_void_0()
{
++count;
}
struct A_void_0
{
void operator()() {++count;}
};
void
test_void_0()
{
int save_count = count;
// function
{
std::reference_wrapper<void ()> r1(f_void_0);
r1();
assert(count == save_count+1);
save_count = count;
}
// function pointer
{
void (*fp)() = f_void_0;
std::reference_wrapper<void (*)()> r1(fp);
r1();
assert(count == save_count+1);
save_count = count;
}
// functor
{
A_void_0 a0;
std::reference_wrapper<A_void_0> r1(a0);
r1();
assert(count == save_count+1);
save_count = count;
}
}
int main()
{
test_void_0();
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/type.pass.cpp b/test/utilities/function.objects/refwrap/type.pass.cpp index a151625bc..0ff125368 100644 --- a/test/utilities/function.objects/refwrap/type.pass.cpp +++ b/test/utilities/function.objects/refwrap/type.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>
// reference_wrapper
// check for member typedef type
#include <functional>
#include <type_traits>
class C {};
int main()
{
static_assert((std::is_same<std::reference_wrapper<C>::type,
C>::value), "");
static_assert((std::is_same<std::reference_wrapper<void ()>::type,
void ()>::value), "");
static_assert((std::is_same<std::reference_wrapper<int* (double*)>::type,
int* (double*)>::value), "");
static_assert((std::is_same<std::reference_wrapper<void(*)()>::type,
void(*)()>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::type,
int*(*)(double*)>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::type,
int*(C::*)(double*)>::value), "");
static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::type,
int (C::*)(double*) const volatile>::value), "");
}
\ 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>
// reference_wrapper
// check for member typedef type
#include <functional>
#include <type_traits>
class C {};
int main()
{
static_assert((std::is_same<std::reference_wrapper<C>::type,
C>::value), "");
static_assert((std::is_same<std::reference_wrapper<void ()>::type,
void ()>::value), "");
static_assert((std::is_same<std::reference_wrapper<int* (double*)>::type,
int* (double*)>::value), "");
static_assert((std::is_same<std::reference_wrapper<void(*)()>::type,
void(*)()>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::type,
int*(*)(double*)>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::type,
int*(C::*)(double*)>::value), "");
static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::type,
int (C::*)(double*) const volatile>::value), "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/unary.pass.cpp b/test/utilities/function.objects/refwrap/unary.pass.cpp index c57292085..411d34fa2 100644 --- a/test/utilities/function.objects/refwrap/unary.pass.cpp +++ b/test/utilities/function.objects/refwrap/unary.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>
// reference_wrapper
// check for deriving from unary_function
#include <functional>
#include <type_traits>
class functor1
: public std::unary_function<int, char>
{
};
class functor2
: public std::binary_function<char, int, double>
{
};
class functor3
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
typedef float result_type;
};
class functor4
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
};
struct C
{
typedef int argument_type;
typedef int result_type;
};
int main()
{
static_assert((std::is_base_of<std::unary_function<int, char>,
std::reference_wrapper<functor1> >::value), "");
static_assert((!std::is_base_of<std::unary_function<char, int>,
std::reference_wrapper<functor2> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, int>,
std::reference_wrapper<functor3> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, int>,
std::reference_wrapper<functor4> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, int>,
std::reference_wrapper<C> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float(*)()> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float (int)> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float (int, int)> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float(*)(int)> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float(*)(int, int)> >::value), "");
static_assert((std::is_base_of<std::unary_function<C*, float>,
std::reference_wrapper<float(C::*)()> >::value), "");
static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
std::reference_wrapper<float(C::*)() const volatile> >::value), "");
static_assert((!std::is_base_of<std::unary_function<C*, float>,
std::reference_wrapper<float(C::*)(int)> >::value), "");
}
\ 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>
// reference_wrapper
// check for deriving from unary_function
#include <functional>
#include <type_traits>
class functor1
: public std::unary_function<int, char>
{
};
class functor2
: public std::binary_function<char, int, double>
{
};
class functor3
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
typedef float result_type;
};
class functor4
: public std::unary_function<int, int>,
public std::binary_function<char, int, double>
{
public:
};
struct C
{
typedef int argument_type;
typedef int result_type;
};
int main()
{
static_assert((std::is_base_of<std::unary_function<int, char>,
std::reference_wrapper<functor1> >::value), "");
static_assert((!std::is_base_of<std::unary_function<char, int>,
std::reference_wrapper<functor2> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, int>,
std::reference_wrapper<functor3> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, int>,
std::reference_wrapper<functor4> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, int>,
std::reference_wrapper<C> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float(*)()> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float (int)> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float (int, int)> >::value), "");
static_assert((std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float(*)(int)> >::value), "");
static_assert((!std::is_base_of<std::unary_function<int, float>,
std::reference_wrapper<float(*)(int, int)> >::value), "");
static_assert((std::is_base_of<std::unary_function<C*, float>,
std::reference_wrapper<float(C::*)()> >::value), "");
static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
std::reference_wrapper<float(C::*)() const volatile> >::value), "");
static_assert((!std::is_base_of<std::unary_function<C*, float>,
std::reference_wrapper<float(C::*)(int)> >::value), "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/refwrap/weak_result.pass.cpp b/test/utilities/function.objects/refwrap/weak_result.pass.cpp index f0935fd39..09cef6642 100644 --- a/test/utilities/function.objects/refwrap/weak_result.pass.cpp +++ b/test/utilities/function.objects/refwrap/weak_result.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>
// reference_wrapper
// has weak result type
#include <functional>
#include <type_traits>
class functor1
: public std::unary_function<int, char>
{
};
class functor2
: public std::binary_function<char, int, double>
{
};
class functor3
: public std::unary_function<char, int>,
public std::binary_function<char, int, double>
{
public:
typedef float result_type;
};
class functor4
: public std::unary_function<char, int>,
public std::binary_function<char, int, double>
{
public:
};
class C {};
template <class T>
struct has_result_type
{
private:
struct two {char _; char __;};
template <class U> static two test(...);
template <class U> static char test(typename U::result_type* = 0);
public:
static const bool value = sizeof(test<T>(0)) == 1;
};
int main()
{
static_assert((std::is_same<std::reference_wrapper<functor1>::result_type,
char>::value), "");
static_assert((std::is_same<std::reference_wrapper<functor2>::result_type,
double>::value), "");
static_assert((std::is_same<std::reference_wrapper<functor3>::result_type,
float>::value), "");
static_assert((std::is_same<std::reference_wrapper<void()>::result_type,
void>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(double*)>::result_type,
int*>::value), "");
static_assert((std::is_same<std::reference_wrapper<void(*)()>::result_type,
void>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::result_type,
int*>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::result_type,
int*>::value), "");
static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::result_type,
int>::value), "");
static_assert((std::is_same<std::reference_wrapper<C()>::result_type,
C>::value), "");
static_assert(has_result_type<std::reference_wrapper<functor3> >::value, "");
static_assert(!has_result_type<std::reference_wrapper<functor4> >::value, "");
static_assert(!has_result_type<std::reference_wrapper<C> >::value, "");
}
\ 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>
// reference_wrapper
// has weak result type
#include <functional>
#include <type_traits>
class functor1
: public std::unary_function<int, char>
{
};
class functor2
: public std::binary_function<char, int, double>
{
};
class functor3
: public std::unary_function<char, int>,
public std::binary_function<char, int, double>
{
public:
typedef float result_type;
};
class functor4
: public std::unary_function<char, int>,
public std::binary_function<char, int, double>
{
public:
};
class C {};
template <class T>
struct has_result_type
{
private:
struct two {char _; char __;};
template <class U> static two test(...);
template <class U> static char test(typename U::result_type* = 0);
public:
static const bool value = sizeof(test<T>(0)) == 1;
};
int main()
{
static_assert((std::is_same<std::reference_wrapper<functor1>::result_type,
char>::value), "");
static_assert((std::is_same<std::reference_wrapper<functor2>::result_type,
double>::value), "");
static_assert((std::is_same<std::reference_wrapper<functor3>::result_type,
float>::value), "");
static_assert((std::is_same<std::reference_wrapper<void()>::result_type,
void>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(double*)>::result_type,
int*>::value), "");
static_assert((std::is_same<std::reference_wrapper<void(*)()>::result_type,
void>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::result_type,
int*>::value), "");
static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::result_type,
int*>::value), "");
static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::result_type,
int>::value), "");
static_assert((std::is_same<std::reference_wrapper<C()>::result_type,
C>::value), "");
static_assert(has_result_type<std::reference_wrapper<functor3> >::value, "");
static_assert(!has_result_type<std::reference_wrapper<functor4> >::value, "");
static_assert(!has_result_type<std::reference_wrapper<C> >::value, "");
}
\ No newline at end of file diff --git a/test/utilities/function.objects/unord.hash/floating.pass.cpp b/test/utilities/function.objects/unord.hash/floating.pass.cpp index 003ba198c..397bcafcf 100644 --- a/test/utilities/function.objects/unord.hash/floating.pass.cpp +++ b/test/utilities/function.objects/unord.hash/floating.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/unord.hash/integral.pass.cpp b/test/utilities/function.objects/unord.hash/integral.pass.cpp index 1e6c0d559..6e5c9add5 100644 --- a/test/utilities/function.objects/unord.hash/integral.pass.cpp +++ b/test/utilities/function.objects/unord.hash/integral.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/unord.hash/pointer.pass.cpp b/test/utilities/function.objects/unord.hash/pointer.pass.cpp index 1a66b5b8c..5cbe83ad9 100644 --- a/test/utilities/function.objects/unord.hash/pointer.pass.cpp +++ b/test/utilities/function.objects/unord.hash/pointer.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/version.pass.cpp b/test/utilities/function.objects/version.pass.cpp index 5b53d1884..293168ba4 100644 --- a/test/utilities/function.objects/version.pass.cpp +++ b/test/utilities/function.objects/version.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>
#include <functional>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}
\ 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>
#include <functional>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}
\ No newline at end of file |