diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
| commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
| tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp | |
| parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) | |
Notes
Diffstat (limited to 'test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp')
| -rw-r--r-- | test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp new file mode 100644 index 000000000000..c0a14fd96fcb --- /dev/null +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// class function<R()> + +// Test that we properly return both values and void for all non-variadic +// overloads of function::operator()(...) + +#define _LIBCPP_HAS_NO_VARIADICS +#include <functional> +#include <cassert> + +int foo0() { return 42; } +int foo1(int) { return 42; } +int foo2(int, int) { return 42; } +int foo3(int, int, int) { return 42; } + +int main() +{ + { + std::function<int()> f(&foo0); + assert(f() == 42); + } + { + std::function<int(int)> f(&foo1); + assert(f(1) == 42); + } + { + std::function<int(int, int)> f(&foo2); + assert(f(1, 1) == 42); + } + { + std::function<int(int, int, int)> f(&foo3); + assert(f(1, 1, 1) == 42); + } + { + std::function<void()> f(&foo0); + f(); + } + { + std::function<void(int)> f(&foo1); + f(1); + } + { + std::function<void(int, int)> f(&foo2); + f(1, 1); + } + { + std::function<void(int, int, int)> f(&foo3); + f(1, 1, 1); + } +} |
