Вопрос

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?

Это было полезно?

Решение

Try using two template parameters:

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

}

Другие советы

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

template <class Archive, typename T>
void serialize( Archive archive, out<T> &var, ... );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top