Class templating std::set key types

Posted by TomFLuff on Stack Overflow See other posts from Stack Overflow or by TomFLuff
Published on 2010-12-23T00:44:46Z Indexed on 2010/12/23 0:54 UTC
Read the original article Hit count: 137

Filed under:
|
|

I have a class to evaluate set algebra but wish to template it.

At the minute it looks a bit like this

set.h:

template<typename T>
  class SetEvaluation
  {
  public:
    SetEvaluation<T>();

    std::set<T>
    evaluate(std::string in_expression);
   }

set.cpp

template<typename T>
   std::set<T>
   SetEvaluation<T>::evaluate(std::string expression)
   {
     std::set<T> result;
     etc etc...
   }

But i'm getting undefined reference errors when compiling.

Is it possible to declare the return type as std::set<T> and then pass std::string as the class template param.

There are no errors in the class but only when I try to instantiate SetEvaluation<std::string>

Can anyone shed light on this problem?

thanks

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates