File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1+ #ifndef Rcpp__traits__is_bool__h
2+ #define Rcpp__traits__is_bool__h
3+
4+ namespace Rcpp { namespace traits {
5+
6+ template <typename >
7+ struct is_bool
8+ : public false_type { };
9+
10+ template <>
11+ struct is_bool <bool >
12+ : public true_type { };
13+
14+ template <>
15+ struct is_bool <const bool >
16+ : public true_type { };
17+
18+ template <>
19+ struct is_bool <volatile bool >
20+ : public true_type { };
21+
22+ }}
23+
24+ #endif
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ struct int2type { enum { value = I }; };
6060#include < Rcpp/traits/is_finite.h>
6161#include < Rcpp/traits/is_infinite.h>
6262#include < Rcpp/traits/is_nan.h>
63+ #include < Rcpp/traits/is_bool.h>
6364#include < Rcpp/traits/if_.h>
6465#include < Rcpp/traits/get_na.h>
6566#include < Rcpp/traits/is_trivial.h>
Original file line number Diff line number Diff line change @@ -120,8 +120,11 @@ class Vector :
120120 }
121121
122122 // 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 ) {
123+ // SFINAE only work for template. Add template class T and then restict T to
124+ // bool.
125+ template <typename T>
126+ Vector (T value,
127+ typename Rcpp::traits::enable_if<traits::is_bool<T>::value && RTYPE == LGLSXP, void >::type* = 0 ) {
125128 Storage::set__ (Rf_allocVector (RTYPE, 1 ));
126129 fill (value);
127130 }
You can’t perform that action at this time.
0 commit comments