vendredi 28 octobre 2016

make_tuple with template parameters does not compile

Consider this code:

#include <tuple>

int main()
{
    int i;
    long k;

    auto tup1 = std::make_tuple<long>(i);   // Compiles
    auto tup2 = std::make_tuple<int>(k);    // Compiles
    auto tup3 = std::make_tuple<int>(i);    // Does not compile
    auto tup4 = std::make_tuple<int>(i+0);  // Compiles
    auto tup5 = std::make_tuple(i);         // Compiles
}

Why does auto tup3 = ... not compile? Apparently, make_tuple<int>(...) wants an rvalue reference as its argument; but why?

(I'm using GCC 6.1.0.)

Aucun commentaire:

Enregistrer un commentaire