David Abrahams wrote:
Ian McCulloch
writes: * Coupling; you need to include a primary template.
Ok, but what does that primary template do? Surely nothing, or some very conservative default.
Actually you don't need to include a primary template. All you need is a declaration with no body. You can do that without even pulling in a header.
I think, an empty body is better than a bare declaration. At least, with template <typename T> struct my_algo_impl {}; you can do SFINAE on whether my_algo_impl<T> is actually defined or not, for some T (ie. using T::result_type, or probably better boost::result_of). This is what I meant by 'doing nothing'; although that was probably not a good way to express it;) By 'conservative default' I meant something like (in the boost::range example) enable_if on whether T does indeed have an end() member function that returns a known iterator type. The last thing you want is a specialization to be viable, but does the wrong thing. Cheers, Ian