Skip to content

Commit af61f01

Browse files
author
thirdwing
committed
use static_cast<R_xlen_t> for type casting
1 parent a0df816 commit af61f01

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

inst/include/Rcpp/sugar/matrix/as_vector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ inline Rcpp::Vector<RTYPE>
3030
as_vector__impl( MatrixBase<RTYPE,NA,T>& t, Rcpp::traits::false_type ){
3131
T& ref = t.get_ref() ;
3232
int nc = ref.ncol(), nr = ref.nrow() ;
33-
Vector<RTYPE> out (((R_xlen_t)nr) * nc) ;
33+
Vector<RTYPE> out (static_cast<R_xlen_t>(nr) * nc) ;
3434
R_xlen_t k =0;
3535
for( int col_index=0; col_index<nc; col_index++)
3636
for( int row_index=0; row_index<nr; row_index++, k++)
@@ -43,7 +43,7 @@ template <int RTYPE, bool NA, typename T>
4343
inline Rcpp::Vector<RTYPE>
4444
as_vector__impl( MatrixBase<RTYPE,NA,T>& t, Rcpp::traits::true_type ){
4545
Matrix<RTYPE>& ref = t.get_ref() ;
46-
R_xlen_t size = ((R_xlen_t)ref.ncol())*ref.nrow() ;
46+
R_xlen_t size = static_cast<R_xlen_t>(ref.ncol())*ref.nrow() ;
4747
typename Rcpp::Vector<RTYPE>::const_iterator first(static_cast<const Rcpp::Vector<RTYPE>&>(ref).begin()) ;
4848
return Vector<RTYPE>(first, first+size );
4949
}

inst/include/Rcpp/sugar/matrix/col.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Col : public MatrixBase<
4040
return j + 1 ;
4141
}
4242

43-
inline R_xlen_t size() const { return ((R_xlen_t)nr) * nc ; }
43+
inline R_xlen_t size() const { return static_cast<R_xlen_t>(nr) * nc ; }
4444
inline int nrow() const { return nr; }
4545
inline int ncol() const { return nc; }
4646

inst/include/Rcpp/sugar/matrix/diag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Diag_Maker : public Rcpp::MatrixBase< RTYPE ,NA, Diag_Maker<RTYPE,NA,T> >
5959
inline STORAGE operator()( int i, int j ) const {
6060
return (i==j) ? object[i] : 0 ;
6161
}
62-
inline R_xlen_t size() const { return ((R_xlen_t)n) * n; }
62+
inline R_xlen_t size() const { return static_cast<R_xlen_t>(n) * n; }
6363
inline int ncol() const { return n; }
6464
inline int nrow() const { return n; }
6565

inst/include/Rcpp/sugar/matrix/lower_tri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class LowerTri : public VectorBase<
4747
return get(i,j) ;
4848
}
4949

50-
inline R_xlen_t size() const { return ((R_xlen_t)nr) * nc ; }
50+
inline R_xlen_t size() const { return static_cast<R_xlen_t>(nr) * nc ; }
5151
inline int nrow() const { return nr; }
5252
inline int ncol() const { return nc; }
5353

inst/include/Rcpp/sugar/matrix/outer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Outer : public MatrixBase<
5757
return converter_type::get( fun( lhs[i], rhs[j] ) );
5858
}
5959

60-
inline R_xlen_t size() const { return ((R_xlen_t)nr) * nc ; }
60+
inline R_xlen_t size() const { return static_cast<R_xlen_t>(nr) * nc ; }
6161
inline int nrow() const { return nr; }
6262
inline int ncol() const { return nc; }
6363

inst/include/Rcpp/sugar/matrix/row.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Row : public MatrixBase<
4040
return i + 1 ;
4141
}
4242

43-
inline R_xlen_t size() const { return ((R_xlen_t)nr) * nc ; }
43+
inline R_xlen_t size() const { return static_cast<R_xlen_t>(nr) * nc ; }
4444
inline int nrow() const { return nr; }
4545
inline int ncol() const { return nc; }
4646

inst/include/Rcpp/sugar/matrix/upper_tri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class UpperTri : public VectorBase<
4242
return get(i,j) ;
4343
}
4444

45-
inline R_xlen_t size() const { return ((R_xlen_t)nr) * nc ; }
45+
inline R_xlen_t size() const { return static_cast<R_xlen_t>(nr) * nc ; }
4646
inline int nrow() const { return nr; }
4747
inline int ncol() const { return nc; }
4848

0 commit comments

Comments
 (0)