functor
A functor, or function object, is a class in C++ with the () operator overloaded. Functors are used a lot in the standard library to do custom comparisons. They're used in place of function pointers because sometimes you need to store a value or remember something (ie. put the functor into a special 'state' for whatever purpose), a functor can do this, a function pointer can't (without messing with global variables).
class over5 { // this class is the functor
bool operator() (int x) {
return x > 5;
}
};
std::list<int> L;
... // put a bunch of ints onto the list
over5 o5;
std::find_if(L.begin(), L.end(), o5);
// o5 will have its overloaded () operator called to check if the element in L is over 5.
bool operator() (int x) {
return x > 5;
}
};
std::list<int> L;
... // put a bunch of ints onto the list
over5 o5;
std::find_if(L.begin(), L.end(), o5);
// o5 will have its overloaded () operator called to check if the element in L is over 5.
functor by Sam Johnston July 23, 2005
Urban Dictionary Merch
Urban Dictionary of Technology
$24.95
chonk
$24.95
based
$24.95
unc
$24.95
yunc
$24.95
baddie
$24.95
bop
$24.95
himbo
$24.95
weeb
$24.95
normie
$24.95
stoner
$24.95
got dressed today
$24.95
iykyk
$24.95
pookie
$24.95
goober
$24.95
tomboy
$24.95
feen
$24.95
goated
$24.95
based
$32.95
baddie
$32.95
bop
$32.95
unc
$32.95
yunc
$32.95
himbo
$32.95
weeb
$32.95
normie
$32.95
stoner
$32.95
got dressed today
$32.95
jorts weather
$32.95
iykyk
$32.95
pookie
$32.95
goober
$32.95
tomboy
$32.95
feen
$32.95
goated
$32.95
based
$49.95
baddie
$49.95
bop
$49.95
unc
$49.95
yunc
$49.95
himbo
$49.95
weeb
$49.95
normie
$49.95
stoner
$49.95
got dressed today
$49.95
iykyk
$49.95
pookie
$49.95
goober
$49.95
tomboy
$49.95
feen
$49.95
goated
$49.95
based
$29.95
unc
$29.95
yunc
$29.95
himbo
$29.95
weeb
$29.95
normie
$29.95
stoner
$29.95
got dressed today
$29.95
iykyk
$29.95
pookie
$29.95
tomboy
$29.95
feen
$29.95
goated
$29.95
demon time
$32.95
boo fucking hoo
$32.95
boo'd up
$32.95
i'm dead
$32.95
vampire hours
$49.95
spoopy
$29.95
boo
$29.95
goblin mode
$49.95
fighting demons
$49.95
batshit
$32.95
touching grass today
$32.95
touching grass today
$49.95