Using constexpr to Improve Security, Performance and Encapsulation in C++—Danny Kalev

Save to:
Instapaper Pocket Readability

How is constexpr different from const, and how does it contribute to making modern C++ code cleaner and simpler, as well as faster than ever? Danny Kalev gives a nice summary:

Using constexpr to Improve Security, Performance and Encapsulation in C++

by Danny Kalev

constexpr is a new C++11 keyword that rids you of the need to create macros and hardcoded literals. It also guarantees, under certain conditions, that objects undergo static initialization. Danny Kalev shows how to embed constexpr in C++ applications to define constant expressions that might not be so constant otherwise.

Continue reading...

Add a Comment

You must sign in or register to add a comment.

Comments (1)

0 0

bkuhns said on Jan 3, 2013 09:17 AM:

"By enforcing compile-time evaluation of its expression"? I was under the impression `constexpr` acted more as a friendly suggestion to the compiler rather than a strict flag of enforcement.