Hello
I have a class with a map where I store some data:
Code:
class someobject {
};
class someclass {
public:
someobject & get_object() {
}
private:
std::map<std::string, someobject> m_map;
};
I'm not sure what would be the best way to implement get_object() function so that it would return reference to the object (if its in the map)..
I know I could leave it like this and do throw catch if the map doesnt contain the object - but thats not the way I want to go..
The next option is to use boost:: optional, but here I have a lot of 'crap' code for instance:
boost:: optional<someobject&> oobject = ...;
Does anyone know of any simpler/better way to implement it?