Files
swift-mirror/test/Interop/Cxx/stdlib/Inputs/std-function.h
Egor Zhdan 2d0863aba2 [cxx-interop] Initial tests for std::function usage
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
2024-01-11 12:02:12 +00:00

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