constexpr always good ? in C++

23 hours ago 1
ARTICLE AD BOX

Are there better methods than `constexpr` in C++? Does constexpr actually provide optimization for cpu or gpu, or does it just increase reliability?

For example,

int maxVolumeCapacity = 10000; // global int height = 10; // global constexpr int volume (int x) { int volume = height * x * x * x; if(volume> maxVolumeCapacity ) { height *= 5; maxVolumeCapacity *= 100; } return volume; }

is this code true or not and does it make sense to use constexpr in this situation?

Read Entire Article