![]() |
Blitz Support : |
From: William Gallafent (william_at_[hidden])
Date: 2004-02-03 21:02:26
Hi,
I'm probably being stupid (it's getting late), but I can't
see why the following (and anything similar, e.g. using a
__gnu_cxx::hash_map, in which case it's operator== which is
in question, rather than operator< as here) shouldn't
compile:
----------
#include <map>
#include <blitz/tinyvec-et.h>
int
main (int argc, char* argv[])
{
std::map<blitz::TinyVector<unsigned, 3>, unsigned> m;
blitz::TinyVector<unsigned, 3> v = 0;
m[v] = 0;
}
----------
Using GCC 3.3, the error output is:
----------
/usr/include/g++/bits/stl_function.h: In member function `bool
std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp =
blitz::TinyVector<unsigned int, 3>]':
/usr/include/g++/bits/stl_map.h:318: instantiated from `_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = blitz::TinyVector<unsigned int, 3>, _Tp = unsigned int, _Compare = std::less<blitz::TinyVector<unsigned int, 3> >, _Alloc = std::allocator<std::pair<const blitz::TinyVector<unsigned int, 3>, unsigned int> >]'
testblitzequals.cpp:10: instantiated from here
/usr/include/g++/bits/stl_function.h:197: error: cannot convert `
blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::TinyVectorIterConst<unsigned
int, 3, 1>, blitz::TinyVectorIterConst<unsigned int, 3, 1>,
blitz::_bz_Less<unsigned int, unsigned int> > >' to `bool' in return
----------
So, although an operator== is found and applied to the two
tinyvectors, its return value is an expression which can't
be converted to bool.
The lines in the STL header which are referenced are:
----------
template <class _Tp>
struct equal_to : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
};
----------
Can anyone shed light? Feel free to point me at
documentation I should have read already!
-- Bill Gallafent.