This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problems using blitz::TinyVector as key for map



Hi,


I'm having problems with using 'find' on a map whose key is a blitz::TinyVector<T, N>. See http://www.oonumerics.org/blitz/ for more information about the Blitz++ library.

Can anyone tell me if I'm doing something wrong, or is this a bug?

Thanks. Faheem.

******************************************************************
g++ -o foo foo.cc

$ ./foo
3 [         50        50        49 ]
3 [          0         0         0 ]

******************************************************************
foo.cc
******************************************************************
#include <iostream>
#include <map>
#include <blitz/array.h>
#include <blitz/tinyvec-et.h>

using std::map;
using std::cout;
using std::endl;

namespace blitz
{
// Less operator (function object) for TinyVector.
template<typename T, int N>
class TinyVectorless
{
public:
inline bool operator() (const blitz::TinyVector<T, N>& u, const blitz::TinyVector<T, N>& v) const
{
return blitz::all(u < v);
}
};
}


int main()
{
map<blitz::TinyVector<int, 3>, int, blitz::TinyVectorless<int, 3> > dict;
dict[blitz::TinyVector<int, 3>(50, 50, 49)] = 0;
dict[blitz::TinyVector<int, 3>(60, 60, 60)] = 1;
blitz::TinyVector<int, 3> x(2, 2, 1000);
blitz::TinyVector<int, 3> y(2, 2, 2);
cout << (dict.find(x))->first << endl;
cout << (dict.find(y))->first << endl;
return 0;
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]