P
Patrick Guio
Dear all,
I would like to use template stream insertion operator for a template
class Foo.
The template class has one template parameter and the template
parameter is of type std::vector<"basic data types"> or
std::vector<std::vector<"basic data types"> >.
Insertion operators can be separated into two types: one for the one
dimension vector and one for the two dimension vector.
I have declared the following three templates declarations in the header
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<T> &f);
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<T> > &f);
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<std::vector<T> > > &f);
and the definition file contains definitions for only the two last
declaration as well as explicit instantiation declarations for the types
I want to support.
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<T> > &f)
{....}
template
std:stream & operator<<(std:stream &os,
const Foo<std::vector<unsigned char> > &f);
....
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<std::vector<T> > > &f)
{...}
template
std:stream & operator<<(std:stream &os,
const Foo<std::vector<std::vector<unsigned char> > > &f);
....
The first template declaration does not have any definition but is used
for the template argument deduction algorithm (I think?)
Is there any other better way to define/declare the template stream
operator for such a template class?
Sincerely,
Patrick
I would like to use template stream insertion operator for a template
class Foo.
The template class has one template parameter and the template
parameter is of type std::vector<"basic data types"> or
std::vector<std::vector<"basic data types"> >.
Insertion operators can be separated into two types: one for the one
dimension vector and one for the two dimension vector.
I have declared the following three templates declarations in the header
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<T> &f);
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<T> > &f);
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<std::vector<T> > > &f);
and the definition file contains definitions for only the two last
declaration as well as explicit instantiation declarations for the types
I want to support.
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<T> > &f)
{....}
template
std:stream & operator<<(std:stream &os,
const Foo<std::vector<unsigned char> > &f);
....
template<typename T>
std:stream & operator<<(std:stream &os,
const Foo<std::vector<std::vector<T> > > &f)
{...}
template
std:stream & operator<<(std:stream &os,
const Foo<std::vector<std::vector<unsigned char> > > &f);
....
The first template declaration does not have any definition but is used
for the template argument deduction algorithm (I think?)
Is there any other better way to define/declare the template stream
operator for such a template class?
Sincerely,
Patrick