File tree Expand file tree Collapse file tree 4 files changed +30
-4
lines changed
Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 1+ 2014-09-14 Kevin Ushey <kevinushey@gmail.com>
2+
3+ * inst/include/Rcpp/vector/Vector.h: Alternate strategy using SFINAE
4+ * inst/include/Rcpp/traits/traits.h: Idem
5+ * inst/include/Rcpp/traits/enable_if.h: Idem
6+
172014-09-13 Kevin Ushey <kevinushey@gmail.com>
28
39 * inst/include/Rcpp/vector/Vector.h: Allow logical vectors to be created
Original file line number Diff line number Diff line change 1+ #ifndef RCPP_TRAITS_ENABLE_IF_H
2+ #define RCPP_TRAITS_ENABLE_IF_H
3+
4+ namespace Rcpp {
5+ namespace traits {
6+
7+ template <bool B, typename T = void >
8+ struct enable_if {};
9+
10+ template <typename T>
11+ struct enable_if <true , T> {
12+ typedef T type;
13+ };
14+
15+ }
16+ }
17+
18+ #endif
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ struct int2type { enum { value = I }; };
3737
3838#include < Rcpp/traits/integral_constant.h>
3939#include < Rcpp/traits/same_type.h>
40+ #include < Rcpp/traits/enable_if.h>
4041#include < Rcpp/traits/is_wide_string.h>
4142#include < Rcpp/traits/char_type.h>
4243#include < Rcpp/traits/named_object.h>
Original file line number Diff line number Diff line change @@ -89,13 +89,13 @@ class Vector :
8989 fill ( u ) ;
9090 }
9191
92- // constructor for CharacterVector()
92+ // constructor for CharacterVector()
9393 Vector ( const std::string& st ){
9494 RCPP_DEBUG_2 ( " Vector<%d>( const std::string& = %s )" , RTYPE, st.c_str () )
9595 Storage::set__ ( internal::vector_from_string<RTYPE>(st) ) ;
9696 }
9797
98- // constructor for CharacterVector()
98+ // constructor for CharacterVector()
9999 Vector ( const char * st ) {
100100 RCPP_DEBUG_2 ( " Vector<%d>( const char* = %s )" , RTYPE, st )
101101 Storage::set__ (internal::vector_from_string<RTYPE>(st) ) ;
@@ -119,8 +119,9 @@ class Vector :
119119 }
120120 }
121121
122- template <typename T = typename Rcpp::traits::if_<RTYPE == LGLSXP, bool , void >::type>
123- Vector (bool value) {
122+ // Enable construction from bool for LogicalVectors
123+ template <int T = RTYPE>
124+ Vector (bool value, typename Rcpp::traits::enable_if<T == LGLSXP, void >::type* = 0 ) {
124125 Storage::set__ (Rf_allocVector (RTYPE, 1 ));
125126 fill (value);
126127 }
You can’t perform that action at this time.
0 commit comments