Static variables should be initalized once instead of initializing them with nullptr and then doing actual initialization behind if condition. Otherwise a race condition may happen leading to undefined behaviour.