c++ - Please explain constexpr -


this question has answer here:

i have class contains 3 static constants,

static const int num_points = 2000; static const float lake_threshold = 0.3; static const int num_lloyd_iterations = 2; 

in header file. realize in c++11 have use constexpr can't figure out how use them. can explain constexpr in simple way?

constexpr can used mark expression compile-time constant. extends functions well, arbitrarily deep call chain can compile-time constant. permits compiler substitute constant value, rather evaluating unnecessarily @ runtime.

see: http://en.cppreference.com/w/cpp/language/constexpr


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -