|
1 | 1 |
|
2 | 2 | // sapply.h: Rcpp R/C++ interface class library -- sapply |
3 | 3 | // |
4 | | -// Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois |
| 4 | +// Copyright (C) 2010 - 2024 Dirk Eddelbuettel and Romain Francois |
| 5 | +// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar |
5 | 6 | // |
6 | 7 | // This file is part of Rcpp. |
7 | 8 | // |
|
27 | 28 | namespace Rcpp{ |
28 | 29 | namespace sugar{ |
29 | 30 |
|
30 | | -template <typename Function, typename SugarExpression> |
31 | | -struct sapply_application_result_of |
32 | | -{ |
33 | | -#if __cplusplus >= 201103L |
34 | | - #if __cplusplus < 201703L |
35 | | - // deprecated by C++17, removed by C++2020, see https://en.cppreference.com/w/cpp/types/result_of |
36 | | - typedef typename ::std::result_of<Function(typename SugarExpression::stored_type)>::type type; |
37 | | - #else |
38 | | - // since C++17, see https://en.cppreference.com/w/cpp/types/result_of |
39 | | - typedef typename ::std::invoke_result<Function, typename SugarExpression::stored_type>::type type; |
40 | | - #endif |
41 | | -#else |
42 | | - // TODO this else branch can likely go |
43 | | - typedef typename ::Rcpp::traits::result_of<Function>::type type; |
44 | | -#endif |
45 | | -}; |
46 | | - |
47 | | -// template <typename Function, typename SugarExpression> |
48 | | -// using sapply_application_result_of_t = typename sapply_application_result_of<Function, SugarExpression>::type; |
49 | | - |
50 | 31 | template <int RTYPE, bool NA, typename T, typename Function, bool NO_CONVERSION> |
51 | 32 | class Sapply : public VectorBase< |
52 | 33 | Rcpp::traits::r_sexptype_traits< |
53 | | - typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type |
| 34 | + typename ::Rcpp::traits::result_of<Function, T>::type |
54 | 35 | >::rtype , |
55 | 36 | true , |
56 | 37 | Sapply<RTYPE,NA,T,Function,NO_CONVERSION> |
57 | 38 | > { |
58 | 39 | public: |
59 | | - typedef typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type result_type ; |
| 40 | + typedef typename ::Rcpp::traits::result_of<Function, T>::type result_type ; |
60 | 41 | const static int RESULT_R_TYPE = |
61 | 42 | Rcpp::traits::r_sexptype_traits<result_type>::rtype ; |
62 | 43 |
|
@@ -87,13 +68,13 @@ class Sapply : public VectorBase< |
87 | 68 | template <int RTYPE, bool NA, typename T, typename Function> |
88 | 69 | class Sapply<RTYPE,NA,T,Function,true> : public VectorBase< |
89 | 70 | Rcpp::traits::r_sexptype_traits< |
90 | | - typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type |
| 71 | + typename ::Rcpp::traits::result_of<Function, T>::type |
91 | 72 | >::rtype , |
92 | 73 | true , |
93 | 74 | Sapply<RTYPE,NA,T,Function,true> |
94 | 75 | > { |
95 | 76 | public: |
96 | | - typedef typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type result_type ; |
| 77 | + typedef typename ::Rcpp::traits::result_of<Function, T>::type result_type ; |
97 | 78 | const static int RESULT_R_TYPE = |
98 | 79 | Rcpp::traits::r_sexptype_traits<result_type>::rtype ; |
99 | 80 |
|
@@ -124,15 +105,15 @@ template <int RTYPE, bool NA, typename T, typename Function > |
124 | 105 | inline sugar::Sapply< |
125 | 106 | RTYPE,NA,T,Function, |
126 | 107 | traits::same_type< |
127 | | - typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type , |
128 | | - typename Rcpp::traits::storage_type< traits::r_sexptype_traits< typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type >::rtype >::type |
| 108 | + typename ::Rcpp::traits::result_of<Function, T>::type , |
| 109 | + typename Rcpp::traits::storage_type< traits::r_sexptype_traits< typename ::Rcpp::traits::result_of<Function, T>::type >::rtype >::type |
129 | 110 | >::value |
130 | 111 | > |
131 | 112 | sapply( const Rcpp::VectorBase<RTYPE,NA,T>& t, Function fun ){ |
132 | 113 | return sugar::Sapply<RTYPE,NA,T,Function, |
133 | 114 | traits::same_type< |
134 | | - typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type , |
135 | | - typename Rcpp::traits::storage_type< traits::r_sexptype_traits< typename ::Rcpp::sugar::sapply_application_result_of<Function, T>::type >::rtype >::type |
| 115 | + typename ::Rcpp::traits::result_of<Function, T>::type , |
| 116 | + typename Rcpp::traits::storage_type< traits::r_sexptype_traits< typename ::Rcpp::traits::result_of<Function, T>::type >::rtype >::type |
136 | 117 | >::value >( t, fun ) ; |
137 | 118 | } |
138 | 119 |
|
|
0 commit comments