Hazel icon indicating copy to clipboard operation
Hazel copied to clipboard

No need for constexpr(?)

Open FillePiano opened this issue 3 years ago • 2 comments

In Hazel/tree/master/Hazel/src/Hazel/Core/Base.h, is there really a need for constexpr. I do not think std::make_shared is constexprable... Am I wrong? I am a noob so would not surprise me.

FillePiano avatar Oct 02 '22 15:10 FillePiano

If std::make_shared wasn't a constexpr I'm pretty sure the compiler would raise an error for that. So to me this looks like the correct use.

Kirdow avatar Oct 05 '22 17:10 Kirdow

The constexpr specifies that the compiler should inline this function, meaning that this:

Ref<T> test = CreateRef<T>();

gets inlined into this:

std::shared_ptr<T> test = std::make_shared<T>();

Peanutt42 avatar Jan 05 '23 23:01 Peanutt42