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