Topic: standalone operators and STL containers
Author: pavel_vozenilek@yahoo.co.uk ("Pavel Vozenilek")
Date: Mon, 25 Apr 2005 15:16:52 GMT Raw View
Standalone operators between STL containers are defined with the same type
T, like:
template<typename T, class Alloc>
bool operator==(const vector<T, Alloc>&, const vector<T, Alloc>&) { ... }
What was reason for not using different types as:
template<typename T1, typename T2, class Alloc>
bool operator==(const vector<T1, Alloc>&, const vector<T2, Alloc>&) { ... }
Then one could easily compare say vector<int> with vector<short>.
Is there a hidden problem with such approach?
/Pavel
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: nesotto@cs.auc.dk ("Thorsten Ottosen")
Date: Tue, 26 Apr 2005 05:22:25 GMT Raw View
""Pavel Vozenilek"" <pavel_vozenilek@yahoo.co.uk> wrote in message
news:3ctoftF6r07h0U1@individual.net...
| Standalone operators between STL containers are defined with the same type
| T, like:
|
| template<typename T, class Alloc>
| bool operator==(const vector<T, Alloc>&, const vector<T, Alloc>&) { ... }
|
|
|
| What was reason for not using different types as:
|
| template<typename T1, typename T2, class Alloc>
| bool operator==(const vector<T1, Alloc>&, const vector<T2, Alloc>&) { ... }
|
|
| Then one could easily compare say vector<int> with vector<short>.
| Is there a hidden problem with such approach?
maybe if T1 = int and T2 = float.
-Thorsten
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]