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.
Comments
Post a Comment