Mythli
Mythli

Reputation: 6305

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

Thankyou for reading

Upvotes: 0

Views: 122

Answers (2)

Tom Kerr
Tom Kerr

Reputation: 10720

Specializing your template should follow this pattern:

template<typename T>
  void foo() {
  }

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

Upvotes: 1

interjay
interjay

Reputation: 110069

It should be:

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

Upvotes: 2

Related Questions