简体   繁体   English

专门功能模板结果

[英]Specialize function template result

I'm pretty new to template metaprogramming and can't find my thinking error in this approach: 我是模板元编程的新手,在这种方法中找不到我的思维错误:

template <typename T>
    typename T::ReturnType Query(const std::string& Str);

template <>
ResultTypeRowCount Query(const std::string& Str) { return this->queryRowCount(Str); }

ResultTypeRowCount implements a public typedef with the name ReturnType ResultTypeRowCount实现名称为ReturnType的公共typedef

Thankyou for reading 谢谢您的阅读

It should be: 它应该是:

template <>
ResultTypeRowCount::ReturnType Query<ResultTypeRowCount>(const std::string& Str) { return this->queryRowCount(Str); }

Specializing your template should follow this pattern: 专门化模板应遵循以下模式:

template<typename T>
  void foo() {
  }

template<>
  void foo<int>() {
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM