mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This makes sure that `std::function` is imported consistently on supported platforms, and that it allows basic usage: calling a function with `callAsFunction`, initializing an empty function, and passing a function retrieved from C++ back to C++ as a parameter. rdar://103979602
17 lines
444 B
C++
17 lines
444 B
C++
#ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_FUNCTION_H
|
|
#define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_FUNCTION_H
|
|
|
|
#include <functional>
|
|
|
|
using FunctionIntToInt = std::function<int(int)>;
|
|
|
|
FunctionIntToInt getIdentityFunction() {
|
|
return [](int x) { return x; };
|
|
}
|
|
|
|
bool isEmptyFunction(FunctionIntToInt f) { return !(bool)f; }
|
|
|
|
int invokeFunction(FunctionIntToInt f, int x) { return f(x); }
|
|
|
|
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_FUNCTION_H
|