mercredi 26 octobre 2016

C++11 tuple get returns incorrect value

I have a variable with a tuple (s is a temporary object used to fill tuple):

auto tmp = getTuple<Args&&...>::get(s);

type of auto is resolved as std::tuple<int&&> and stored value is 12 (in debugger seen as 12 - int&&) (seen in debugger in runtime). If I do

auto ii = std::get<0>(tmp);

And print ii (ii is resolved as int), I got "undefined" value (-858993460). However, on another computer, I got correct 12. This seems like an undefined behaviour, but I dont know why.

Aucun commentaire:

Enregistrer un commentaire