lundi 2 janvier 2017

c++11. How to get element from tuple without const [duplicate]

This question already has an answer here:

I'm trying to do this.

int flag = 0;
if(big.size() <= small.size())
  flag = 1; //use float

tuple<long, float> tup (1234.5678, 12341234.1234); 
auto foo = get<flag>(tup);  

But I get errors:

error: the value of 'flag' is not usable in a constant expression
   cout << get<flag>(tup);  

-and-

 note: 'int flag' is not const
 int flag = 0;

Aucun commentaire:

Enregistrer un commentaire