1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <functional> 11 12// class function<R()> 13 14// Test that we properly return both values and void for all non-variadic 15// overloads of function::operator()(...) 16 17#define _LIBCPP_HAS_NO_VARIADICS 18#include <functional> 19#include <cassert> 20 21int foo0() { return 42; } 22int foo1(int) { return 42; } 23int foo2(int, int) { return 42; } 24int foo3(int, int, int) { return 42; } 25 26int main() 27{ 28 { 29 std::function<int()> f(&foo0); 30 assert(f() == 42); 31 } 32 { 33 std::function<int(int)> f(&foo1); 34 assert(f(1) == 42); 35 } 36 { 37 std::function<int(int, int)> f(&foo2); 38 assert(f(1, 1) == 42); 39 } 40 { 41 std::function<int(int, int, int)> f(&foo3); 42 assert(f(1, 1, 1) == 42); 43 } 44 { 45 std::function<void()> f(&foo0); 46 f(); 47 } 48 { 49 std::function<void(int)> f(&foo1); 50 f(1); 51 } 52 { 53 std::function<void(int, int)> f(&foo2); 54 f(1, 1); 55 } 56 { 57 std::function<void(int, int, int)> f(&foo3); 58 f(1, 1, 1); 59 } 60} 61