I have already posted and discussed the following problems once, but
despite really helpful hints I did not get any further with my problem
(I at least learned, first to exactly consider why something does not
work instead of immediately searching for work arounds) . I have the
following code resulting in an ambiguity:
--------------------------------------------------------
template <typename Impl>
class Vector {};
template <typename Ref>
class VectorView : public Vector<VectorVi ew<Ref> >
{
public:
operator const Ref &() const { return _ref; }
private:
Ref _ref;
};
template <typename T>
class DenseVector : public Vector<DenseVec tor<T> >
{
public:
DenseVector() {}
template <typename Impl>
DenseVector(con st Vector<Impl> &rhs) {}
VectorView<Dens eVector<T> >
operator()(int from, int to) { return VectorView<Dens eVector<T>
(); }
};
int amin(const DenseVector<dou ble> &x) { return 1; }
int amin(const DenseVector<flo at> &x) { return -1; }
int main()
{
DenseVector<dou ble> x;
int i = amin(x(1,3));
}
--------------------------------------------------------
Some things are not really clear to me:
1) what causes the ambiguity. The conversion operator in
class VectorView returns a DenseVector<dou ble>. Why is any further
conversion considered as I have an exact matching function amin?
2) It's the templated constructor of DenseVector causing the trouble.
I cannot make it explicit, what would work in the example. Is there
another way to have this constructor, but prevent it from being
considered a candidate, if Impl is DenseVector<T2> ?
best regards,
Alex