Rcpp Version 1.1.2
Loading...
Searching...
No Matches
InternalFunctionWithStdFunction.h
Go to the documentation of this file.
1//
2// InternalFunction_with_std_function.h: Rcpp R/C++ interface class library -- exposing C++ std::function's
3//
4// Copyright (C) 2014 - 2025 Christian Authmann
5// Copyright (C) 2015 - 2025 Romain Francois and Dirk Eddelbuettel
6//
7// This file is part of Rcpp.
8//
9// Rcpp is free software: you can redistribute it and/or modify it
10// under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 2 of the License, or
12// (at your option) any later version.
13//
14// Rcpp is distributed in the hope that it will be useful, but
15// WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21
22#ifndef Rcpp_InternalFunctionWithStdFunction_h
23#define Rcpp_InternalFunctionWithStdFunction_h
24
25#include <Rcpp/internal/call.h>
26#include <functional>
27
28namespace Rcpp {
29
31
32 template <typename RESULT_TYPE, typename... Args>
34 public:
35 CppFunctionBaseFromStdFunction(const std::function<RESULT_TYPE(Args...)> &fun) : fun(fun) {}
37
38 SEXP operator()(SEXP* args) {
40 return call<decltype(fun), RESULT_TYPE, Args...>(fun, args);
42 }
43
44 private:
45 const std::function<RESULT_TYPE(Args...)> fun;
46 };
47
48 } // namespace InternalFunctionWithStdFunction
49} // namespace Rcpp
50
51#endif
#define END_RCPP
Definition macros.h:99
#define BEGIN_RCPP
Definition macros.h:49
Rcpp API.
Definition algo.h:28