Here is a simple question regarding const correctness.
I have this class:
template <class T>
class Foo
{
public:
std::map<std::string, boost::any> members;
template <typename T>
std::vector<T>& member(const std::string& memberName)
{
return boost::any_cast<std::vector<T>&>(members[memberName]);
}
};
Then I have a functor that includes the following:
bool operator()(Foo& foo) const
{
std::vector<T> & member = foo.member<T>(_memberName);
What bothers me is that I cannot pass Foo a reference to const, since I call the getter non-member function. As for his signature, it seems that the operator () changes foo.
Should I fix this, and if so, how?
source
share