I'm currently looking for a somewhat more flexible associative container
than std::map that can do the following:
std::map< keyT, valT, lessOp > m;
keyT K;
otherT O; // lessOp and operator== were defined to work "between" keyT
_and_ otherT, see below
... fill the map ...
m[K] = valT("blubb");
assert( K == T ); // lets say K and T were build the way this assertion
always holds
it = m.find[O]; // bang
std::map can't do that, just because find( const keyT& ) is definde only
for keyT
->compiler error
but, as for the concept of an associative container it should be enough
that a otherT can be comparet to the maps keyT,
or will this lead to further problems?
some template members like
template< typname otherT >
...iterator... find( const otherT& ) { ... }
in the map template definition should do? probably not all of the map
implemention must be rewritten.
but if it works, someone must have done it before, and I don't want to
invent the map again :)
thanks for your ideas ...
####################################
// defined before code above:
// comparing struct:
struct lessOp {
bool operator()( const keyT& k, const otherT& o );
bool operator()( const otherT& o, const keyT& k );
bool operator()( const keyT& k, const keyT& k );
}
//... and a functions to test for equality
bool operator==( const keyT& k, const otherT& o );
bool operator==( const otherT& k, const keyT& o );
bool operator==( const keyT& k, const keyT& o );
####################################
|