GCC 3.4.6 to GCC 4.1.1 migration

Thomas Mittelstaedt T.Mittelstaedt@cadenas.de
Wed May 30 09:42:00 GMT 2007


Can you give a complete code sample?

Nasredine Semmar schrieb:
> Le vendredi 25 mai 2007 13:53, vous avez écrit :
>
> It's the STL Find function but the compiler does not recognize it.
>
> I added #include <algorithm> but I got the same error. 
>
> Here is the class where the function find is called:
>
> #if __GNUC__>2 
> #include <ext/hash_map>
> using __gnu_cxx::hash_map;
> using __gnu_cxx::hash;
> #else
> #include <hash_map>
> #endif
> template<class A,class B>
> class leda_h_array : public MY_HASH_BASE
> {
> private:
>   B init;
> public:
>   leda_h_array() {}
>   leda_h_array(const B&_init)
>     : MY_HASH_BASE(),init(_init) {}
>   bool defined(const A&a) const
>     { return find(a)!= this->end(); }
>   const B&operator[](const A&a)const
>     { 
>       typename MY_HASH_BASE::const_iterator pos=find(a);
>       
>       if( pos== this->end() )
> 	return init;
>       else
> 	return pos->second;
>     }
>   B&operator[](const A&a)
>     { 
>       typename MY_HASH_BASE::iterator pos=find(a);
>       if( pos== this->end() )
> 	{
> 	  insert(typename MY_HASH_BASE::value_type(a,init));
> 	  pos=find(a);
> 	  iassert(pos!= this->end());
> 	}
>       return pos->second;
>     }
> };
>
> Thanks,
>
> Nasredine
>   



More information about the Gcc-help mailing list