From: Erik Z. <ze...@ma...> - 2008-06-11 17:52:52
|
On Wed, Jun 11, 2008 at 6:15 AM, Xu Haihua <g06...@nu...> wrote: > > Hi everyone: > I have compiler error when I use TinyVector with STL set. > > I tried to insert the term to the set<TinyVector<int,2> > but have > compiler problem. (compiler is MSVC8) > Can anyone give me an example how to use set with TinyVector<int,2>? > Thanks. > > > The program is below: > > #include "stdafx.h" > #include <blitz/array.h> > #include <blitz/tinyvec.h> > #include<set> > > using namespace std; > using namespace blitz; > int main() > { > set<TinyVector<int,2> > myset; > TinyVector<int,2> term; > term[0]=1; > term[1]=2; > myset.insert(term); > } > std::set requires a comparison (<) operator returning a single bool. TinyVector returns an expression template that is (I believe) convertible to TinyVector<bool, 2>, not a bool. You'll need to supply your own comparison function (the second template argument to std::set). Erik -- ************************************************* Erik Zeek ze...@ma... ************************************************* Against stupidity the very gods Themselves contend in vain. - Johann Christoph Friedrich von Schiller (1801) ************************************************* |