Blah &Class::GetSomething()
{
return something;
}
const Blah &Class::GetSomething() const
{
return something;
}
(Note: My actual code, in this specific case, isn't just an accessor - it's looking through a vector to find the right element to return)The end result is that I have a two functions with identical code, but only the function declaration is different. How can I safely use the definition of one to implement both of them?
Here's the code I'm currently wanting to use it on, but I've hit the same situation several times previously:
Layer::Ptr &Floor::GetLayer(const LayerName &layerName)
{
for(auto &layer : this->Layers)
{
if(layer->Name == layerName)
return layer;
}
static Layer::Ptr dummy;
return dummy;
}






