0

I'm porting Windows code to Linux. So, i have a code

 template <typename PROPERTY,typename T_COORDINATE=am3::model::Coordinates>
  struct Provider
  {
    virtual PROPERTY GetState(am3::model::common::Point<T_COORDINATE>* point,const PROPERTY* const typeTrait)=0;
        virtual PROPERTY GetState(am3::model::common::Point<T_COORDINATE>* point)
        {
            const PROPERTY* const typeTrait_=nullptr;
            return this->GetState(point,typeTrait_);
        }
    template <typename T>
    PROPERTY GetState(am3::model::common::Point<T_COORDINATE>* point);
    template <>
    PROPERTY GetState<PROPERTY>(am3::model::common::Point<T_COORDINATE>* point)
    {
      const PROPERTY* const typeTrait_=nullptr;
      return this->GetState(point,typeTrait_);
    }
  };

and MSVC compiling it without problems, but g++ show me error: explicit specialization in non-namespace scope ‘struct am3::model::contract::Provider’

I tried overload it, specialize function after struct body and more, (Specialization of templated member function in templated class etc, etc..) but I'm stuck now. Has anyone an idea, how to do it? Many thanks in advance!

Community
  • 1
  • 1
kamilw7
  • 33
  • 3
  • As the answer for the question you linked says: `You cannot specialize a member without also specializing the class`. Take a look at http://stackoverflow.com/a/10178791/1147772 and in general [avoid specialising function templates](http://www.gotw.ca/publications/mill17.htm) – Drax Oct 06 '14 at 13:45
  • I was on this page too. When I tried "template [...] template " error was: error: function template partial specialization ‘GetState’ is not allowed – kamilw7 Oct 06 '14 at 13:56
  • Yep, you can't partially specialise function templates, as the linked question i posted in the previous comments suggest, you could transform that into a template class with a static function. But i'm afraid you will need to change the way it is called in the rest of the code. – Drax Oct 06 '14 at 14:03
  • It's my general problem - i can't change rest of code, because my code is only one of many libraries. But many thanks for your suggestions/ – kamilw7 Oct 06 '14 at 14:08

0 Answers0