c++11 - c++ auto with overriding signed/unsigned -


in following code:

#include <armadillo>  using namespace arma;  int main() {     mat a;     auto x=a.n_rows-5;     .... 

x long long unsigned int , want long long int. how can fix problem?

it should noticed on different versions of library, different types have been used, cannot mention long long int directly , need use auto.

you can use c++11 type traits library signed or unsigned version of numeric type.

to unsigned int:

std::make_unsigned<int>::type 

so signed version of a.n_rows, try:

std::make_signed<decltype(a.n_rows)>::type x = a.n_rows - 5; 

for other qualifiers, there corresponding templates convert between types:


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -