【问题标题】:What's an empty template for? [duplicate]空模板有什么用? [复制]
【发布时间】:2021-12-29 23:00:27
【问题描述】:

我一直在寻找如何在 LLVM 中使用 YAML。而且我不明白他们为什么使用空模板。例如,here

template <>
struct ScalarEnumerationTraits<FooBar> {
  static void enumeration(IO &io, FooBar &value) {
  ...
  }
};

template &lt;&gt; 是干什么用的?

这不是 What is the meaning of empty "<>" in template usage? 的副本。

【问题讨论】:

    标签: c++ templates


    【解决方案1】:

    这是template specialization。你会在某个地方找到类似的东西:

    template <typename C>
    struct ScalarEnumerationTraits;
    

    您看到的是该声明对FooBar 类型的特化。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-30
      • 1970-01-01
      • 2023-03-04
      • 2020-05-12
      • 2022-01-14
      • 1970-01-01
      • 2016-03-03
      相关资源
      最近更新 更多