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
31namespace 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>
40 public:
41 CppFunctionBaseFromStdFunction(const std::function<RESULT_TYPE(Args...)> &fun) : fun(fun) {}
43
46 return call<decltype(fun), RESULT_TYPE, Args...>(fun, args);
48 }
49
50 private:
51 const std::function<RESULT_TYPE(Args...)> fun;
52 };
53
54 } // namespace InternalFunctionWithStdFunction
55} // namespace Rcpp
56
57#endif
#define END_RCPP
Definition macros.h:99
#define BEGIN_RCPP
Definition macros.h:49
Rcpp API.
Definition algo.h:28
T as(SEXP x)
Definition as.h:151