Home

<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

previous
next

Re: What does the syntax [::-1] really mean?
Re: Override 'and' and 'or'
Re: unexpected optparse set_default/set_defaults behavior
Writing Scalabe Software in C++
Re: Python 3.0 migration plans?
Kidprotect
Mam Marzenie
Akogo
Fundacja Sloneczko
Rodzic Po Ludzku