I have code with the following basic structure:
namespace A{
template<class T,unsigned DIM>
class CMyTable{
...
public:
template<class T,unsigned DIM>
friend std::ostream& operator<<(std::ostream& s, const CMyTable<T,DIM>& vec);
}
};
}
The initial problem was to get my operator<< outside the namespace A.
I tried this solution : How do I define friends in global namespace within another C++ namespace?
namespace A{
template<class T,unsigned DIM>
class CMyTable;
}
template<class T,unsigned DIM>
std::ostream& operator<<(std::ostream& s, const CMyTable<T,DIM>& vec);
namespace A{
template<class T,unsigned DIM>
class CMyTable{
...
public:
template<class T,unsigned DIM>
friend std::ostream& ::operator<<(std::ostream& s, const CMyTable<T,DIM>& vec);
}
};
}
template<class T,unsigned DIM>
std::ostream& operator<<(std::ostream& s, const CMyTable<T,DIM>& vec){
// [...]
}
I got this error : error C2063: 'operator <<' : not a function inside the class declaration.
public:
template<class T,unsigned DIM>
friend std::ostream& ::operator<<(std::ostream& s, const CMyTable<T,DIM>&
Does anyone have any ideas ?
Thanks.