Try using functors (function objects) instead. STL has great support for them, and you could use unique addresses from instances as your index. Additionally, you could make indices like this:Quote:
Originally posted by DeepBlackMagic
its required for an index.
Code:#include <functional>
struct my_func : public std::binary_function<std::string, int, void>
{
void operator()(std::string str, int x)
{
// ...
}
};
void foo()
{
std::unary_function<std::string, void> func1 = std::bind2nd(my_func(), 1);
std::unary_function<std::string, void> func2 = std::bind2nd(my_func(), 2);
}