/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/cpp11_std_function.i
32 строки
731 B
William S Fulton
Remove need for additional %rename for std::function
03 май 2026, 21:00
03 май 2026, 21:00
ebd01b7
Код
Авторство
О чём код?
%module cpp11_std_function %header %{ #include <functional> #include <string> #include <stdexcept> %} %include <std_string.i> %include <std_function.i> %include <exception.i> %inline %{ std::function<bool(int, const std::string &)> pass_checker(int pass) { return [pass](int passcode, const std::string &name) -> bool { return passcode == pass && name == "Petka"; }; } %} %template(cpp_lambda) std::function<bool(int, const std::string &)>; // Expose a wrapper function to call the functor %inline %{ template <typename RET, typename... ARGS> RET call_std_function(std::function<RET(ARGS...)> fn, ARGS ...args) { return fn(args...); } %} %template(call_function) call_std_function<bool, int, const std::string &>;