| 434 | |
| 435 | template <typename Function> |
| 436 | void define(const std::string &name, Function&& func) { |
| 437 | typedef utility::function_traits<Function> traits; |
| 438 | |
| 439 | auto funcPtr = new auto(std::forward<Function>(func)); |
| 440 | if(int result = sqlite3_create_function_v2( |
| 441 | _db.get(), name.c_str(), traits::arity, SQLITE_UTF8, funcPtr, |
| 442 | sql_function_binder::scalar<traits::arity, typename std::remove_reference<Function>::type>, |
| 443 | nullptr, nullptr, [](void* ptr){ |
| 444 | delete static_cast<decltype(funcPtr)>(ptr); |
| 445 | })) |
| 446 | errors::throw_sqlite_error(result); |
| 447 | } |
| 448 | |
| 449 | template <typename StepFunction, typename FinalFunction> |
| 450 | void define(const std::string &name, StepFunction&& step, FinalFunction&& final) { |
no test coverage detected