Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 1.18 KB

CppConstexpr.md

File metadata and controls

25 lines (16 loc) · 1.18 KB

constexpr is a C++11 keyword for generalized constant expressions. In other words, constexpr indicates that an expression will always return the same values, thus rendering this return value a compile-time constant.

  • Use constexpr whenever possible [2,3]

External links

  1. GCC page about C++0x support
  2. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 12.7. Advice. page 341: '[5] If a function may have to be evaluated at compile time, declare it constexpr'
  3. Scott Meyers. Effective Modern C++ (1st Edition). 2014. ISBN: 978-1-491-90399-5. Item 15 'Use constexpr whenever possible'