
hello,
I have a class A that holds a container of objects of type B indexed by int
for e.g.
Typically, I have a function of A
class A {
public:
const B& getB(int <index> ) const;
private:
std::map< int, shared_ptr<B> > listOfBs_;
};
The implementation of getB could be
const B& A::getB(int <index> ) const
{
//what to do if index not found
}
A number of solutions I think of:
1.
boost::optional