In this template function, I am trying to retrieve at element from a boost ptr_map. I have omitted error handling code for clarity.
template <typename K, class T>
class A
{
public:
void TryGet(const K &key, T &o) { o = mObjects.at(key); }
private:
boost::ptr_map<K, T> mObjects;
};
typedef A<std::string, B> myClass;
I get the compiler error C2582: 'operator =' function is unavailable in 'B'. Why does the assignment of the return value of mObjects.at() to a reference need access to an assignment operator of the instantiated class? What is the correct way to return this value?