lundi 23 février 2015

Overload resolution with rvalue reference to const char *


#include <iostream>

using namespace std;

void f(const char * const &s) {
cout << "lvalue" << endl;
}

void f(const char * const &&s) {
cout << "rvalue" << endl;
}

int main()
{
char s[] = "abc";

f("abc");
f(s);
}


Output:



rvalue
rvalue


Why isn't the output "rvalue lvalue"?


Aucun commentaire:

Enregistrer un commentaire