dimanche 26 août 2018

Is this expression an xvalue?

The C++ standard says the following about 'xvalues' (N4762 § 7.2.1.4):

An expression is an xvalue if it is:
- . . .
- a class member access expression designating a non-static data member of non-reference type in which the object expression is an xvalue

Consider the following code fragment (using Boost to print the type of an expression):

#include <iostream>
#include <boost/type_index.hpp>

using boost::typeindex::type_id_with_cvr;

struct X {
    int var;
} x;

int main()
{
    std::cout << type_id_with_cvr<decltype( std::move(x).var )>().pretty_name() << std::endl;
}

My question is about the expression: std::move(x).var

Based on the text in the standard, I expect the expression to be an xvalue, but the output is int, not int &&

What am I missing here ?

Aucun commentaire:

Enregistrer un commentaire