c++ - 类命名空间内的模板特化

标签 c++ namespaces template-specialization information-hiding

如何特化类主体中某个外部命名空间中定义的模板?

使用不编译的 BGL 的具体示例:

class A
{
  namespace boost
  {
    template <class ValueType>
    struct container_gen<SomeSelectorS, ValueType>
    {
      typedef std::multiset<ValueType,MyClass<ValueType> > type;
    };
  }
}

如果将 container_gen 的特化移出 A 类,一切都会很好。具体问题是我不知道如何从 A 类引用“boost”命名空间。

最佳答案

您不能在类内创建命名空间,也不能在类内的命名空间范围内特化模板。

关于c++ - 类命名空间内的模板特化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3470047/

相关文章:

c++ - WIN32 API C 程序 : Combo Box has an empty list or not dropping down despite populating with CB_ADDSTRING

xml - 如何使用 xslt 向元素添加变量命名空间

c++ - 单函数的类部分模板特化,如何解决其他成员的未定义错误

c++ - 模板特化编译器错误

c++ - 多个枚举值的一个模板特化

c++ - 在 C++ 中,* 用于哪三件事?

java - 概率模拟误差不收敛

c++ - opencv stereoRectifyUncalibrated 的问题

xslt - 如何使用 xslt 处理 xml 命名空间的存在与否

c++ - 命名空间和私有(private)变量如何在汇编中工作?