C++
General Tips
Difference between
constexpr
andconst
const
prevents variables from being modified,constexpr
tells the compiler that an expression results in a compile-time constantOnly values known at compile time can be assigned to
constexpr
When applied to functions,
const
can only be used for non-static member functionsGuarentees the member function does not modify any non-static data members
constexpr
can be used with member and non-member functionsDeclares function fit for use in constant expressions
Arguments and return types must be literal types
Links
Last updated