阅读背景:

为什么原语类型和用户定义类型在从函数返回“const”时行为不同?

来源:互联网 
#include <iostream>using namespace std;template<typename T>void f(T&&) { cout << "f(T&&)" << endl; }template<typename T>void f(const T&&) { cout << "f(const T&&)" << endl; }struct A {};const A g1() { return {}; }const int g2() { return {}; }int main(){    f(g1()); // outputs "f(const T&&)" as expected.    f(g2()); // outputs "f(T&&)" not as expected.}#include <iostream>using namespace std;template



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: