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
28
namespace
Rcpp
{
29
30
namespace
InternalFunctionWithStdFunction
{
31
32
template
<
typename
RESULT_TYPE,
typename
... Args>
33
class
CppFunctionBaseFromStdFunction
:
public
CppFunctionBase
{
34
public
:
35
CppFunctionBaseFromStdFunction
(
const
std::function<RESULT_TYPE(Args...)> &
fun
) :
fun
(
fun
) {}
36
virtual
~CppFunctionBaseFromStdFunction
() {}
37
38
SEXP
operator()
(SEXP* args) {
39
BEGIN_RCPP
40
return
call<
decltype
(
fun
), RESULT_TYPE, Args...>(
fun
, args);
41
END_RCPP
42
}
43
44
private
:
45
const
std::function<RESULT_TYPE(Args...)>
fun
;
46
};
47
48
}
// namespace InternalFunctionWithStdFunction
49
}
// namespace Rcpp
50
51
#endif
Rcpp::CppFunctionBase::CppFunctionBase
CppFunctionBase()
Definition
CppFunction.h:33
Rcpp::InternalFunctionWithStdFunction::CppFunctionBaseFromStdFunction::~CppFunctionBaseFromStdFunction
virtual ~CppFunctionBaseFromStdFunction()
Definition
InternalFunctionWithStdFunction.h:36
Rcpp::InternalFunctionWithStdFunction::CppFunctionBaseFromStdFunction::fun
const std::function< RESULT_TYPE(Args...)> fun
Definition
InternalFunctionWithStdFunction.h:45
Rcpp::InternalFunctionWithStdFunction::CppFunctionBaseFromStdFunction::CppFunctionBaseFromStdFunction
CppFunctionBaseFromStdFunction(const std::function< RESULT_TYPE(Args...)> &fun)
Definition
InternalFunctionWithStdFunction.h:35
Rcpp::InternalFunctionWithStdFunction::CppFunctionBaseFromStdFunction::operator()
SEXP operator()(SEXP *args)
Definition
InternalFunctionWithStdFunction.h:38
END_RCPP
#define END_RCPP
Definition
macros.h:99
BEGIN_RCPP
#define BEGIN_RCPP
Definition
macros.h:49
Rcpp::InternalFunctionWithStdFunction
Definition
InternalFunctionWithStdFunction.h:30
Rcpp
Rcpp API.
Definition
algo.h:28
inst
include
Rcpp
InternalFunctionWithStdFunction.h
Generated on
for Rcpp Version 1.1.2 by
1.15.0