<chsalvia@gmail.com> wrote in message...
>
> An alternative would be to define eq as a functor, like:
>
> struct eq {
> bool operator() (const char_type c1, const char_type c2) { return
> c1 == c2; }
> }
>
> The major difference, of course, is that the second case requires you
> to ** instantiate the object. **
See if this will compile for you.
// #includes here <cstdlib>, <iostream>, <vector>, <algorithm>,etc.
struct MyRand{
int operator()(){ return std::rand() % 100;}
};
int main(){
std::vector<int> vLf;
std::generate_n( std::back_inserter( vLf ), 1000, MyRand() );
// or is that what you meant by 'instantiate'
std::vector<int>::const_iterator it =
std::max_element(vLf.begin(), vLf.end());
std::cout<<"vector<int> vLf.size()"<<vLf.size()
<<" The largest element is "<<*it<<std::endl;
return 0;
} // main()
Maybe I mis-understood.
--
Bob R
POVrookie