79098463

Date: 2024-10-17 14:10:23
Score: 0.5
Natty:
Report link

In registerClass, you can't use operator[] because in case the provided key doesn't exist in the map, a default constructed reference_wrapper should be instantiated. However, this is not possible since it makes no sense to create an object supposed to encapsulate a reference without any reference.

On the other hand, you could first test the existence of the key with find and then insert the new entry if needed:

if (getRegistry().find(id) == getRegistry().end())
{
    getRegistry().insert ({id,std::ref(ds)});
}

or you can simply as @AhmedAEK suggested use emplace.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @AhmedAEK
  • Low reputation (0.5):
Posted by: edrezen