0

I am forward declaring a template outer and inner class as follows

template<class T>
class outer;

class inner;

Just after the above declaration I have a boost::serialization declaration defined as

namespace boost
{
    namespace serialization
    {
         template<class Archive> 
         void serialize(Archive &ar, outer &var, ...) { }
    }

}

Outer is a template class and thus requires specification of template arguments. If I attempt to do so as follows

...
     void serialize(... outer<T> &var ... ) { }
...

this is an error as only one template declaration is allowed. What is the proper way to define such a forward declaration?

Mushy
  • 2,535
  • 10
  • 33
  • 54
  • If im not wrong you should do: template template void serialize(Archive &ar, outer &var, ...) { }. i dont remember but i think you can also put the templates in one line: template – Ariel Pinchover May 09 '13 at 11:52
  • 2
    Why can't you use template ? – tmaric May 09 '13 at 11:52
  • @tomislav-maric I thought I needed to separate template declarations; I thought they were unique and should not be mixed. I will do what you are suggesting. Put up an answer and I will up-vote and mark. – Mushy May 09 '13 at 14:52
  • @Mushy thanks for waiting, I answered.. :) – tmaric May 09 '13 at 19:19

2 Answers2

2

Try using two template parameters:

namespace boost
{
    namespace serialization
    {
         template<class Archive, class T> 
         void serialize(Archive &ar, outer<T>& var, ...) { }
    }

}
tmaric
  • 5,347
  • 4
  • 42
  • 75
1

I might have misunderstood, but can you not do this:

template <class Archive, typename T>
void serialize( Archive archive, out<T> &var, ... );
RandyGaul
  • 1,915
  • 14
  • 21