Skip to content

Commit 926b8b8

Browse files
authored
Use variadic templates unconditionally (#1367)
* Use variadic templates unconditionally in module/class.h Remove four generated files * Use variadic templates unconditionally in grow.h Remove one generated file * Use variadic templates unconditionally in DottedPair.h Remove one generated file * Use variadic templates unconditionally in Vector.h Remove one generated file * Use variadic templates unconditionally in Function.h Remove one generated file * Use variadic templates unconditionally in call.h and also in InternalFunctionWithStdFunction.h Remove one generated file * Use variadic templates unconditionally in Module.h Remove nine generated files * Use variadic templates unconditionally in traits/index_sequece.h and traits/named_object.h * Use variadic templates unconditionally in Language.h Remove one generated file * Use variadic templates unconditionally in DataFrame.h Remove one generated file * Use variadic templates unconditionally in Pairlist.h Remove one generated file * Use variadic templates unconditionally in InternalFunction.h Remove one generated file * No longer define HAS_VARIADIC_TEMPLATES * Roll micro release and date * Remove a leftover comment line [ci ski]
1 parent 257e197 commit 926b8b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+203
-55449
lines changed

ChangeLog

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,49 @@
1+
2025-03-18 Dirk Eddelbuettel <edd@debian.org>
2+
3+
* DESCRIPTION (Version, Date): Roll micro version and date
4+
* inst/include/Rcpp/config.h: Idem
5+
6+
* inst/include/Rcpp/module/class.h: Use variadic templates unconditionally
7+
* inst/include/Rcpp/grow.h: Idem
8+
* inst/include/Rcpp/DottedPair.h: Idem
9+
* inst/include/Rcpp/Vector.h: Idem
10+
* inst/include/Rcpp/Function.h: Idem
11+
* inst/include/Rcpp/internal/call.h: Idem
12+
* inst/include/Rcpp/InternalFunctionWithStdFunction.h: Idem
13+
* inst/include/Rcpp/Module.h: Idem
14+
* inst/include/Rcpp/traits/index_sequence.h: Idem
15+
* inst/include/Rcpp/traits/named_object.h: Idem
16+
* inst/include/Rcpp/Language.h: Idem
17+
* inst/include/Rcpp/DataFrame.h: Idem
18+
* inst/include/Rcpp/PairList.h: Idem
19+
* inst/include/Rcpp/InternalFunction.h: Idem
20+
21+
* inst/include/Rcpp/module/Module_generated_class_constructor.h: Removed
22+
* inst/include/Rcpp/module/Module_generated_class_factory.h: Idem
23+
* inst/include/Rcpp/module/Module_generated_method.h: Idem
24+
* inst/include/Rcpp/module/Module_generated_Pointer_method.h: Idem
25+
* inst/include/Rcpp/generated/grow__pairlist.h: Idem
26+
* inst/include/Rcpp/generated/DottedPair__ctors.h: Idem
27+
* inst/include/Rcpp/generated/Vector__create.h: Idem
28+
* inst/include/Rcpp/generated/Function__operator.h: Idem
29+
* inst/include/Rcpp/generated/InternalFunctionWithStdFunction_call.h: Idem
30+
* inst/include/Rcpp/module/Module_generated_Constructor.h: Idem
31+
* inst/include/Rcpp/module/Module_generated_CppFunction.h: Idem
32+
* inst/include/Rcpp/module/Module_generated_CppMethod.h: Idem
33+
* inst/include/Rcpp/module/Module_generated_Factory.h: Idem
34+
* inst/include/Rcpp/module/Module_generated_Pointer_CppMethod.h: Idem
35+
* inst/include/Rcpp/module/Module_generated_class_signature.h: Idem
36+
* inst/include/Rcpp/module/Module_generated_ctor_signature.h: Idem
37+
* inst/include/Rcpp/module/Module_generated_function.h: Idem
38+
* inst/include/Rcpp/module/Module_generated_get_signature.h: Idem
39+
* inst/include/Rcpp/generated/Language__ctors.h: Idem
40+
* inst/include/Rcpp/generated/DataFrame_generated.h: Idem
41+
* inst/include/Rcpp/generated/Pairlist__ctors.h: Idem
42+
* inst/include/Rcpp/generated/InternalFunction__ctors.h: Idem
43+
44+
* inst/include/Rcpp/platform/compiler.h: No longer define HAS_VARIADIC_TEMPLATES
45+
* src/api.cpp (rcpp_can_use_cxx0x): Return true unconditionally
46+
147
2025-03-15 Dirk Eddelbuettel <edd@debian.org>
248

349
* DESCRIPTION (Version, Date): Roll micro version and date

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 1.0.14.7
4-
Date: 2025-03-15
3+
Version: 1.0.14.8
4+
Date: 2025-03-17
55
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org",
66
comment = c(ORCID = "0000-0001-6419-907X")),
77
person("Romain", "Francois", role = "aut",

inst/include/Rcpp/DataFrame.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// DataFrame.h: Rcpp R/C++ interface class library -- data frames
44
//
5-
// Copyright (C) 2010 - 2021 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -117,14 +117,10 @@ namespace Rcpp{
117117
static DataFrame_Impl create(){
118118
return DataFrame_Impl() ;
119119
}
120-
#if defined(HAS_VARIADIC_TEMPLATES)
121-
template <typename... T>
122-
static DataFrame_Impl create(const T&... args) {
123-
return DataFrame_Impl::from_list(Parent::create(args...));
124-
}
125-
#else
126-
#include <Rcpp/generated/DataFrame_generated.h>
127-
#endif
120+
template <typename... T>
121+
static DataFrame_Impl create(const T&... args) {
122+
return DataFrame_Impl::from_list(Parent::create(args...));
123+
}
128124

129125
private:
130126
void set__(SEXP x){

inst/include/Rcpp/DottedPair.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// DottedPair.h: Rcpp R/C++ interface class library -- dotted pair list template
44
//
5-
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -35,14 +35,10 @@ RCPP_API_CLASS(DottedPair_Impl),
3535
DottedPair_Impl(SEXP x) {
3636
Storage::set__(x) ;
3737
}
38-
#if defined(HAS_VARIADIC_TEMPLATES)
39-
template <typename... T>
40-
DottedPair_Impl(const T&... args) {
41-
Storage::set__(pairlist(args...));
42-
}
43-
#else
44-
#include <Rcpp/generated/DottedPair__ctors.h>
45-
#endif
38+
template <typename... T>
39+
DottedPair_Impl(const T&... args) {
40+
Storage::set__(pairlist(args...));
41+
}
4642

4743
void update(SEXP){}
4844

inst/include/Rcpp/Function.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,10 @@ namespace Rcpp{
8282
return Rcpp_fast_eval(call, R_GlobalEnv);
8383
}
8484

85-
#if defined(HAS_VARIADIC_TEMPLATES)
86-
template <typename... T>
87-
SEXP operator()(const T&... args) const {
85+
template <typename... T>
86+
SEXP operator()(const T&... args) const {
8887
return invoke(pairlist(args...), R_GlobalEnv);
89-
}
90-
#else
91-
#include <Rcpp/generated/Function__operator.h>
92-
#endif
88+
}
9389

9490
/**
9591
* Returns the environment of this function

inst/include/Rcpp/InternalFunction.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626

2727
#include <Rcpp/grow.h>
2828

29-
#ifdef RCPP_USING_CXX11
3029
#include <Rcpp/InternalFunctionWithStdFunction.h>
31-
#endif
3230

3331
namespace Rcpp{
3432

@@ -37,7 +35,6 @@ namespace Rcpp{
3735

3836
RCPP_GENERATE_CTOR_ASSIGN(InternalFunction_Impl)
3937

40-
#ifdef RCPP_USING_CXX11
4138
template <typename RESULT_TYPE, typename... Args>
4239
InternalFunction_Impl(const std::function<RESULT_TYPE(Args...)> &fun) {
4340
set(
@@ -51,9 +48,6 @@ namespace Rcpp{
5148
InternalFunction_Impl(RESULT_TYPE (*fun)(T...)) {
5249
set(XPtr<CppFunctionN<RESULT_TYPE, T...> >(new CppFunctionN<RESULT_TYPE, T...>(fun), true));
5350
}
54-
#else
55-
#include <Rcpp/generated/InternalFunction__ctors.h>
56-
#endif
5751

5852
void update(SEXP){}
5953
private:

inst/include/Rcpp/InternalFunctionWithStdFunction.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
21
//
32
// InternalFunction_with_std_function.h: Rcpp R/C++ interface class library -- exposing C++ std::function's
43
//
5-
// Copyright (C) 2014 Christian Authmann
6-
// Copyright (C) 2015 Romain Francois and Dirk Eddelbuettel
4+
// Copyright (C) 2014 - 2025 Christian Authmann
5+
// Copyright (C) 2015 - 2025 Romain Francois and Dirk Eddelbuettel
76
//
87
// This file is part of Rcpp.
98
//
@@ -23,17 +22,12 @@
2322
#ifndef Rcpp_InternalFunctionWithStdFunction_h
2423
#define Rcpp_InternalFunctionWithStdFunction_h
2524

26-
#if defined(HAS_VARIADIC_TEMPLATES)
2725
#include <Rcpp/internal/call.h>
28-
#endif
2926
#include <functional>
3027

3128
namespace Rcpp {
3229

3330
namespace InternalFunctionWithStdFunction {
34-
#if !defined(HAS_VARIADIC_TEMPLATES) && !defined(RCPP_USING_CXX11)
35-
#include <Rcpp/generated/InternalFunctionWithStdFunction_call.h>
36-
#endif
3731

3832
template <typename RESULT_TYPE, typename... Args>
3933
class CppFunctionBaseFromStdFunction : public CppFunctionBase {

inst/include/Rcpp/Language.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// Language.h: Rcpp R/C++ interface class library -- language objects (calls)
33
//
4-
// Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
55
//
66
// This file is part of Rcpp.
77
//
@@ -102,19 +102,15 @@ namespace Rcpp{
102102
* 0.0 is wrapped as a numeric vector using wrap( const& double )
103103
* ...
104104
*/
105-
#if defined(HAS_VARIADIC_TEMPLATES)
106-
template <typename... T>
107-
Language_Impl(const std::string& symbol, const T&... t) {
108-
Storage::set__(pairlist(Rf_install(symbol.c_str()), t...) );
109-
}
105+
template <typename... T>
106+
Language_Impl(const std::string& symbol, const T&... t) {
107+
Storage::set__(pairlist(Rf_install(symbol.c_str()), t...) );
108+
}
110109

111-
template <typename... T>
112-
Language_Impl(const Function& function, const T&... t) {
113-
Storage::set__(pairlist(function, t...));
114-
}
115-
#else
116-
#include <Rcpp/generated/Language__ctors.h>
117-
#endif
110+
template <typename... T>
111+
Language_Impl(const Function& function, const T&... t) {
112+
Storage::set__(pairlist(function, t...));
113+
}
118114

119115
/**
120116
* sets the symbol of the call

inst/include/Rcpp/Module.h

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// Module.h: Rcpp R/C++ interface class library -- Rcpp modules
33
//
4-
// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
55
//
66
// This file is part of Rcpp.
77
//
@@ -86,7 +86,6 @@ namespace Rcpp{
8686
#include <Rcpp/module/CppFunction.h>
8787
#include <Rcpp/module/get_return_type.h>
8888

89-
#if defined(HAS_VARIADIC_TEMPLATES)
9089
namespace Rcpp {
9190
template <typename RESULT_TYPE, typename... T>
9291
inline void signature(std::string& s, const char* name) {
@@ -132,11 +131,7 @@ namespace Rcpp {
132131
Rcpp::List formals;
133132
};
134133
}
135-
#else
136-
#include <Rcpp/module/Module_generated_get_signature.h>
137-
// templates CppFunction0, ..., CppFunction65
138-
#include <Rcpp/module/Module_generated_CppFunction.h>
139-
#endif
134+
140135
#include <Rcpp/module/class_Base.h>
141136
#include <Rcpp/module/Module.h>
142137

@@ -177,7 +172,7 @@ namespace Rcpp{
177172
private:
178173
ParentMethod* parent_method_pointer ;
179174
} ;
180-
#if defined(HAS_VARIADIC_TEMPLATES)
175+
181176
template <typename... T>
182177
inline void ctor_signature(std::string& s, const std::string& classname) {
183178
s.assign(classname);
@@ -251,13 +246,6 @@ namespace Rcpp{
251246
return nargs == n ;
252247
}
253248

254-
#else
255-
#include <Rcpp/module/Module_generated_ctor_signature.h>
256-
#include <Rcpp/module/Module_generated_Constructor.h>
257-
#include <Rcpp/module/Module_generated_Factory.h>
258-
#include <Rcpp/module/Module_generated_class_signature.h>
259-
#endif
260-
261249
typedef bool (*ValidConstructor)(SEXP*,int) ;
262250
typedef bool (*ValidMethod)(SEXP*,int) ;
263251

@@ -381,7 +369,7 @@ namespace Rcpp{
381369

382370
} ;
383371

384-
#if defined(HAS_VARIADIC_TEMPLATES)
372+
385373
template <bool IsConst,typename Class, typename RESULT_TYPE, typename... T>
386374
class CppMethodImplN : public CppMethod<Class> {
387375
public:
@@ -441,10 +429,8 @@ namespace Rcpp{
441429

442430
template <typename Class, typename RESULT_TYPE, typename... T>
443431
using Const_Pointer_CppMethodN = Pointer_CppMethodImplN<true, Class, RESULT_TYPE, T...>;
444-
#else
445-
#include <Rcpp/module/Module_generated_CppMethod.h>
446-
#include <Rcpp/module/Module_generated_Pointer_CppMethod.h>
447-
#endif
432+
433+
448434

449435
template <typename Class>
450436
class CppProperty {
@@ -552,7 +538,7 @@ namespace Rcpp{
552538
} ;
553539
}
554540

555-
#if defined(HAS_VARIADIC_TEMPLATES)
541+
556542
namespace Rcpp {
557543
template <typename RESULT_TYPE, typename... T>
558544
void function(const char* name_, RESULT_TYPE (*fun)(T... t), const char* docstring = 0) {
@@ -570,10 +556,7 @@ namespace Rcpp {
570556
}
571557
}
572558
}
573-
#else
574-
// function factories
575-
#include <Rcpp/module/Module_generated_function.h>
576-
#endif
559+
577560

578561
namespace Rcpp {
579562

inst/include/Rcpp/Pairlist.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Pairlist.h: Rcpp R/C++ interface class library -- pair lists objects (LISTSXP)
44
//
5-
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -42,14 +42,11 @@ namespace Rcpp{
4242
Pairlist_Impl(SEXP x){
4343
Storage::set__(r_cast<LISTSXP>(x)) ;
4444
}
45-
#if defined(HAS_VARIADIC_TEMPLATES)
46-
template <typename... T>
47-
Pairlist_Impl(const T&... args ){
48-
Storage::set__(pairlist(args... )) ;
49-
}
50-
#else
51-
#include <Rcpp/generated/Pairlist__ctors.h>
52-
#endif
45+
template <typename... T>
46+
Pairlist_Impl(const T&... args ){
47+
Storage::set__(pairlist(args... )) ;
48+
}
49+
5350
void update(SEXP x) {
5451
if (TYPEOF(x) != LISTSXP) {
5552
Storage::set__(r_cast<LISTSXP>(x));

0 commit comments

Comments
 (0)