阅读背景:

一个程序,它不使用默认参数,它不能绑定到引用参数,合法吗?

来源:互联网 

Consider the following:

考虑以下:

#include <iostream>

template <typename T>
struct Foo
{
    Foo (T v = {}) : var (v) {}
    T var;
};

int main()
{
    // Foo<int&> f;  // cannot compile

   int x = 42;
   Foo<int&> f(x);
   std::cout << f.var;
}
#include <ios



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

分享到: