Download

[Code] Do you think NULL could be replaced with nullptr?

I have been looking at this and this SO questions when I noticed that some places in Unreal Engine uses NULL.

Has there been considerations on changing NULL to nullptr in certain contexts, or it was to be put off for backwards compatibility?

Yes, it definitely could. You’ll see that new code should generally use nullptr instead of NULL. There have been discussions in the past about doing a full-scale search and replace conversion, however, those kind of sweeping changes can cause a lot of headaches for teams merging their own engine changes when taking engine upgrades, so to this point it has not yet been done on a whole-sale replacement basis.

I see then. May I suggest that when the time comes for Unreal Engine 5 to come out, you could set forth a forced guideline telling the developers to use nullptr instead of NULL? It could work for transitioning to a completely new engine, similar to UE3 to UE4 would be.

I’ve always used nullptr in my own code and I urge people to do the same.

The only time I’m used NULL on purpose is in a custom data container that requires the implicit conversion between NULL and 0.

You may want to check to see if it is both NULL or 0. I had to use nullptr, NULL, and 0 for a pointer in one case.