|
1 | 1 | // Vector.h: Rcpp R/C++ interface class library -- vectors
|
2 | 2 | //
|
3 |
| -// Copyright (C) 2010 - 2024 Dirk Eddelbuettel and Romain Francois |
| 3 | +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois |
4 | 4 | //
|
5 | 5 | // This file is part of Rcpp.
|
6 | 6 | //
|
@@ -1120,55 +1120,56 @@ class Vector :
|
1120 | 1120 | return Vector( 0 ) ;
|
1121 | 1121 | }
|
1122 | 1122 |
|
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 | + } |
1131 | 1131 |
|
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 | + } |
1154 | 1140 |
|
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 | + } |
1172 | 1173 |
|
1173 | 1174 | public:
|
1174 | 1175 |
|
|
0 commit comments