阅读背景:

为什么使用范围解析运算符更改全局命名空间中哪个重载模板被调用?

来源:互联网 

Consider the following code:

请考虑以下代码:

#include <iostream>

template <class W, class T>
void foo(W& a, T& t)
{
  std::cout << "generic" << std::endl;
}

template <template <bool> class W, class T>
void foo(W<true>& a, const T& t)
{
  foo(a, const_cast<T&>(t));
}

template <class W>
void foo(W& a, int& t)
{
  std::cout << "int" << std::endl;
}

template <bool> struct what;
template<> struct what<true> { };

int main() {
  const int ci = 10;
  what<true> wt;

  foo(wt, ci);

  return 0;
}
#incl



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

分享到: