
From: Michael Stevens <mail@michael-stevens.de>
[snip]
template<class V> void hard (V &data, const typename vector_range<V>::range_type &r) {} template<class V> void hard (vector_slice<V> &data, const typename vector_slice<V>::range_type &r) {}
main () { vector_slice<int> vs; simple (vs, range() ); hard (vs, range() ); }
There are no problems with the functions 'simple'. It thinks the functions 'hard' are ambiguous despite the fact that the first parameter is more specialised in the second version. It seems to be disturbed by template parameter dependence of the second parameter.
Anyone know of a workaround?
What about shifting "const" around? template <class V> void hard(V &data, typename vector_range<V>::range_type const &r) {} template <class V> void hard(vector_slice<V> &data, typename vector_slice<V>::range_type const &r) {} What about putting them in a class template? Then you could introduce typedefs to simplify the expressions the compiler must grok. (WARNING: No compiler has had opportunity to comment on the following code.) template <class V> struct hard_helper { typedef typename vector_range<V>::range_type range_type; void apply(V &data, range_type const &r) {} }; template <class V> struct hard_helper<vector_slice<V> > { typedef typename vector_slice<V>::range_type range_type; void apply(V &data, range_type const &r) {} }; template <class V, class R> inline void hard(V &data, R const &r) { hard_helper<V>::apply(data, r); } -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;