mercredi 31 juillet 2019

Why is a variable not an lvalue in C++?

#include <type_traits>

int main()
{    
    int n;
    n = 0;

    // failure!
    static_assert(std::is_lvalue_reference_v<decltype(n)>); 
}

n can be put on the left side, so it should be obviously an lvalue.

Why does the static_assert fail?

Aucun commentaire:

Enregistrer un commentaire