could anybody tell what I'm doing wrong?
template <typename T, std::size_t D>
class DTree;
template <class is, typename T, std::size_t D>
is& operator>>(is& i_stream, DTree<T, D> &tree);
template <typename T, std::size_t D>
class DTreeProxy
{
public:
template <class is, typename TT, std::size_t DD>
friend is& operator>> (is& i_stream, DTree<T, D> &tree);
private: typedef int Blah;
};
template <class is, typename T, std::size_t D>
is& operator>>(is& i_stream, DTree<T, D> &tree)
{
typedef typename DTreeProxy<T, D>::Blah Blah; // Error
}
The error is then that Blah is private in the operator>>() context.
I'm lost. How should it be done ?
Many thanks in advance,
Fokko Beekhof
The bug lies here: You have to use DD and TT - not D and T in the
parameter list of the function.
template <class is, typename TT, std::size_t DD>
friend is& operator>> (is& i_stream, DTree<TT, DD> &tree);
As far as i know, it's not possible to declare a friend given a
partial set of template arguments. Either you have to declare
particular instances as friends, or all possible instances of a
template. The above declares all ones as friends. The below declares
one particular instance as friend.
friend istream& operator>> <>(istream& i_stream, DTree<T, D> &tree);
Now, whether the specialization was instantiated or explicitly
specialized - it will be a friend.