Skip to content

Commit 7487e18

Browse files
committed
Fixing ambiguity in operator+ for Vector/Matrix, scalar
1 parent e2cb4f3 commit 7487e18

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

inst/include/Rcpp/sugar/operators/plus.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,20 @@ namespace sugar{
442442

443443
}
444444

445-
template <int RTYPE,bool NA, typename T>
445+
template <int RTYPE,bool NA, typename T, typename U>
446446
inline sugar::Plus_Vector_Primitive<RTYPE,NA,T>
447447
operator+(
448448
const VectorBase<RTYPE,NA,T>& lhs,
449-
typename traits::storage_type<RTYPE>::type rhs
449+
U rhs
450450
) {
451451
return sugar::Plus_Vector_Primitive<RTYPE,NA,T>( lhs, rhs ) ;
452452
}
453453

454454

455-
template <int RTYPE,bool NA, typename T>
455+
template <int RTYPE,bool NA, typename T, typename U>
456456
inline sugar::Plus_Vector_Primitive< RTYPE , NA , T >
457457
operator+(
458-
typename traits::storage_type<RTYPE>::type rhs,
458+
U rhs,
459459
const VectorBase<RTYPE,NA,T>& lhs
460460
) {
461461
return sugar::Plus_Vector_Primitive<RTYPE,NA, T >( lhs, rhs ) ;

inst/include/Rcpp/vector/Matrix.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ inline std::ostream &operator<<(std::ostream & s, const Matrix<REALSXP, StorageP
248248
}
249249

250250
#define RCPP_GENERATE_MATRIX_SCALAR_OPERATOR(__OPERATOR__) \
251-
template <int RTYPE, template <class> class StoragePolicy > \
251+
template <int RTYPE, template <class> class StoragePolicy, typename T > \
252252
inline Matrix<RTYPE, StoragePolicy> operator __OPERATOR__ (const Matrix<RTYPE, StoragePolicy> &lhs, \
253-
const typename Matrix<RTYPE, StoragePolicy>::stored_type &rhs) { \
253+
T rhs) { \
254254
Vector<RTYPE, StoragePolicy> v = static_cast<const Vector<RTYPE, StoragePolicy> &>(lhs) __OPERATOR__ rhs; \
255255
v.attr("dim") = Vector<INTSXP>::create(lhs.nrow(), lhs.ncol()); \
256256
return as< Matrix<RTYPE, StoragePolicy> >(v); \
@@ -264,8 +264,8 @@ RCPP_GENERATE_MATRIX_SCALAR_OPERATOR(/)
264264
#undef RCPP_GENERATE_MATRIX_SCALAR_OPERATOR
265265

266266
#define RCPP_GENERATE_SCALAR_MATRIX_OPERATOR(__OPERATOR__) \
267-
template <int RTYPE, template <class> class StoragePolicy > \
268-
inline Matrix<RTYPE, StoragePolicy> operator __OPERATOR__ (const typename Matrix<RTYPE, StoragePolicy>::stored_type &lhs, \
267+
template <int RTYPE, template <class> class StoragePolicy, typename T > \
268+
inline Matrix<RTYPE, StoragePolicy> operator __OPERATOR__ (T lhs, \
269269
const Matrix<RTYPE, StoragePolicy> &rhs) { \
270270
Vector<RTYPE, StoragePolicy> v = static_cast<const Vector<RTYPE, StoragePolicy> &>(rhs); \
271271
v = lhs __OPERATOR__ v; \

0 commit comments

Comments
 (0)