Skip to content

Commit 8235db9

Browse files
committed
Use variadic templates unconditionally in Vector.h
Remove one generated file
1 parent 7654d5e commit 8235db9

File tree

3 files changed

+51
-173
lines changed

3 files changed

+51
-173
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
* inst/include/Rcpp/module/class.h: Use variadic templates unconditionally
44
* inst/include/Rcpp/grow.h: Idem
55
* inst/include/Rcpp/DottedPair.h: Idem
6+
* inst/include/Rcpp/Vector.h: Idem
67

78
* inst/include/Rcpp/module/Module_generated_class_constructor.h: Removed
89
* inst/include/Rcpp/module/Module_generated_class_factory.h: Idem
910
* inst/include/Rcpp/module/Module_generated_method.h: Idem
1011
* inst/include/Rcpp/module/Module_generated_Pointer_method.h: Idem
1112
* inst/include/Rcpp/generated/grow__pairlist.h: Idem
1213
* inst/include/Rcpp/generated/DottedPair__ctors.h: Idem
14+
* inst/include/Rcpp/generated/Vector__create.h: Idem
1315

1416
2025-03-15 Dirk Eddelbuettel <[email protected]>
1517

inst/include/Rcpp/generated/DottedPair__ctors.h

Lines changed: 0 additions & 125 deletions
This file was deleted.

inst/include/Rcpp/vector/Vector.h

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vector.h: Rcpp R/C++ interface class library -- vectors
22
//
3-
// Copyright (C) 2010 - 2024 Dirk Eddelbuettel and Romain Francois
3+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
44
//
55
// This file is part of Rcpp.
66
//
@@ -1120,55 +1120,56 @@ class Vector :
11201120
return Vector( 0 ) ;
11211121
}
11221122

1123-
#if defined(HAS_VARIADIC_TEMPLATES)
1124-
public:
1125-
template <typename... T>
1126-
static Vector create(const T&... t){
1127-
return create__dispatch( typename traits::integral_constant<bool,
1128-
traits::is_any_named<T...>::value
1129-
>::type(), t... ) ;
1130-
}
1123+
// #if defined(HAS_VARIADIC_TEMPLATES)
1124+
public:
1125+
template <typename... T>
1126+
static Vector create(const T&... t){
1127+
return create__dispatch( typename traits::integral_constant<bool,
1128+
traits::is_any_named<T...>::value
1129+
>::type(), t... ) ;
1130+
}
11311131

1132-
private:
1133-
template <typename... T>
1134-
static Vector create__dispatch(traits::false_type, const T&... t){
1135-
Vector res(sizeof...(T)) ;
1136-
iterator it(res.begin());
1137-
create_dispatch_impl(it, t...);
1138-
return res;
1139-
}
1140-
template <typename... T>
1141-
static Vector create__dispatch( traits::true_type, const T&... t) {
1142-
Vector res(sizeof...(T)) ;
1143-
Shield<SEXP> names(::Rf_allocVector(STRSXP, sizeof...(T)));
1144-
int index = 0;
1145-
iterator it(res.begin());
1146-
replace_element_impl(it, names, index, t...);
1147-
res.attr("names") = names;
1148-
return res;
1149-
}
1150-
template <typename T>
1151-
static void create_dispatch_impl(iterator& it, const T& t) {
1152-
*it = converter_type::get(t);
1153-
}
1132+
private:
1133+
template <typename... T>
1134+
static Vector create__dispatch(traits::false_type, const T&... t){
1135+
Vector res(sizeof...(T)) ;
1136+
iterator it(res.begin());
1137+
create_dispatch_impl(it, t...);
1138+
return res;
1139+
}
11541140

1155-
template <typename T, typename... TArgs>
1156-
static void create_dispatch_impl(iterator& it, const T& t, const TArgs&... args) {
1157-
*it = converter_type::get(t);
1158-
create_dispatch_impl(++it, args...);
1159-
}
1160-
template <typename T>
1161-
static void replace_element_impl(iterator& it, Shield<SEXP>& names, int& index, const T& t) {
1162-
replace_element(it, names, index, t);
1163-
}
1164-
template <typename T, typename... TArgs>
1165-
static void replace_element_impl(iterator& it, Shield<SEXP>& names, int& index, const T& t, const TArgs&... args) {
1166-
replace_element(it, names, index, t);
1167-
replace_element_impl(++it, names, ++index, args...);
1168-
}
1169-
#else
1170-
#include <Rcpp/generated/Vector__create.h>
1171-
#endif
1141+
template <typename... T>
1142+
static Vector create__dispatch( traits::true_type, const T&... t) {
1143+
Vector res(sizeof...(T)) ;
1144+
Shield<SEXP> names(::Rf_allocVector(STRSXP, sizeof...(T)));
1145+
int index = 0;
1146+
iterator it(res.begin());
1147+
replace_element_impl(it, names, index, t...);
1148+
res.attr("names") = names;
1149+
return res;
1150+
}
1151+
1152+
template <typename T>
1153+
static void create_dispatch_impl(iterator& it, const T& t) {
1154+
*it = converter_type::get(t);
1155+
}
1156+
1157+
template <typename T, typename... TArgs>
1158+
static void create_dispatch_impl(iterator& it, const T& t, const TArgs&... args) {
1159+
*it = converter_type::get(t);
1160+
create_dispatch_impl(++it, args...);
1161+
}
1162+
1163+
template <typename T>
1164+
static void replace_element_impl(iterator& it, Shield<SEXP>& names, int& index, const T& t) {
1165+
replace_element(it, names, index, t);
1166+
}
1167+
1168+
template <typename T, typename... TArgs>
1169+
static void replace_element_impl(iterator& it, Shield<SEXP>& names, int& index, const T& t, const TArgs&... args) {
1170+
replace_element(it, names, index, t);
1171+
replace_element_impl(++it, names, ++index, args...);
1172+
}
11721173

11731174
public:
11741175

0 commit comments

Comments
 (0)