P
phdscholar80
I am using the following code:
#include <vector>
#include <algorithm>
class A
{
};
bool comparator( A * b, const char * a )
{
// return appropriate true/false value
}
int main( int argc, char * argv[] )
{
std::vector< A * > vt;
const char * p = "a";
std::lower_bound( vt.begin(), vt.end(), p, comparator );
return 0;
}
Note that the second argument of the comparator function is the same
as 'p', the 'object' that is being provided. Is this a standard
compliant technique? If not, shouldn't the standard allow this? It
comes in useful in a LOT of situations. (Incase you are wondering,
this worked perfectly on Visual Studio 2003 but doesn't work on Visual
Studio 2005 with SP1).
#include <vector>
#include <algorithm>
class A
{
};
bool comparator( A * b, const char * a )
{
// return appropriate true/false value
}
int main( int argc, char * argv[] )
{
std::vector< A * > vt;
const char * p = "a";
std::lower_bound( vt.begin(), vt.end(), p, comparator );
return 0;
}
Note that the second argument of the comparator function is the same
as 'p', the 'object' that is being provided. Is this a standard
compliant technique? If not, shouldn't the standard allow this? It
comes in useful in a LOT of situations. (Incase you are wondering,
this worked perfectly on Visual Studio 2003 but doesn't work on Visual
Studio 2005 with SP1).