c++ - Container of sets using non-default comparison predicate -


i create std::map<t1, std::set<t2> > sets use non-default comparator. example, if declaring set on own, declare as:

std::set<int,bool(*)(int,int)> s (fn_pt); 

where fn_pt function pointer. in example, when add new key std::map, set constructed non-default comparator. such thing possible?

to further complicate things, compiler not support c++11, can accept solution not require c++11; however, if there c++11 way of doing this, interested in seeing well.

since can use functor should able use:

struct compare {     bool operator () (int lhs, int rhs) { return lhs - 10 < rhs; } };   int main() {     std::map<int, std::set<int, compare> > data; } 

each new set created in map default constructed type specified in template parameters.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -