Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-27 06:16:45


From: "Ed Brey" <edbrey_at_[hidden]>
> From: "Peter Dimov" <pdimov_at_[hidden]>
>
> > template<class R> void sort(R & r)
> > {
> > std::sort(r.begin(), r.end());
> > }
> >
> > template<class T> void sort(std::list<T> & l)
> > {
> > l.sort();
> > }
>
> I don't follow. Why does the std::list<T>& overload prevent the other
> function from being R const& ?

Technically it doesn't; I'm thinking in std terms:

Library requirements for sort:

template<class R> void sort(R const & r);

Specialization:

template<class T> void sort(std::list<T> & l);

Does not meet requirements, undefined behavior.

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk