www.digitalmars.com         C & C++   DMDScript  

c++.beta - namespace using declaration and templates

In the sample below, if you remove the using declaration and fix up the
manipulator to be fully qualified, it works. Otherwise, it fails with an illegal
operand type. The sample below works when templates are converted to
non-templates. This is probably part of the problem with "using std::endl",
which results in an endl template not instantiated error.

namespace ns {

template <class T1> struct A {
A<T1>& operator<<(A<T1>& (*m)(A<T1>&)) { return m(*this); }
};

template <class T2> inline A<T2>& fn(A<T2>& test) { return test; }

} //ns

using ns::fn;

int main() {
ns::A<int> a;
a << fn;
// Error: illegal operand types
// Had: ns::A<>
}

Richard
Feb 28 2003