constexpr Functions

constexpr functions are functions that can be executed at compile time. Sounds not so thrilling. But it is. Trust me. You can perform with constexpr functions a lot of calculations at compile time. Therefore, the result of the calculation is at runtime as a constant in ROM available. In addition, constexpr functions are implicitly inline.

Read more
Tags: constexpr
Views: 61996

constexpr - Variables and Objects

If you declare a variable as constexpr the compiler will evaluate them at compile time. This holds not only true for built-in types but also for instantiations of user-defined types. There are a few serious restrictions for objects in order to evaluate them at compile time.

 

Read more
Tags: constexpr
Views: 32352

Constant Expressions with constexpr

You can define with the keyword constexpr an expression that can be evaluated at compile time. constexpr can be used for variables, functions, and user-defined types. An expression that is evaluated at compile time has a lot of advantages. For example, constexpr variables and instances of user-defined types are automatically thread-safe and can be stored in ROM; constexpr functions that are evaluated at compile-time, are totally done with their work at run time.

Read more
Tags: constexpr
Views: 14262

inline

Thanks to inline the compiler can replace the function call by the function body. There are two reasons to use inline functions: performance and safety.

Read more
Tags: inline
Views: 16878

The Null Pointer Constant nullptr

The new null pointer nullptr cleans up in C++ with the ambiguity of the number 0 and the macro NULL.

Read more
Tags: nullptr
Views: 31015

override and final

By using the context-sensitive keyword override and final you can explicitly manage the overriding of virtual functions. In particular, the keyword override solves a lot of issues with difficulty finding bugs in object hierarchies: Methods that should override methods of base classes. The result is a syntactically but not semantically correct program. The program performs the wrong stuff in the right way.

Read more
Views: 55612

Strongly-Typed Enums

Enumerations are a convenient way to define integer constants with names. These integer constants are called enumerators. Sadly, classical enums have a few drawbacks.

Read more
Tags: enum
Views: 46329

Raw and Cooked

C++11 has user-defined literals for characters, C strings, integers and floating point numbers. For integers and floating point numbers they are available in raw and cooked form. Thanks to C++14 we have built-in literals for binary numbers, C++ strings, complex numbers, and time units.

Read more
Views: 17995

User-Defined Literals

User-defined literals are a unique feature in all mainstream programming languages. They empower you to combine values with units.

Read more
Views: 35321

Published at Leanpub: The C++ Standard Library

Just published: The C++ Standard Library: What every professional C++ programmer should know about the C++ standard library.

Read more
Views: 13533

My Newest E-Books

Course: Modern C++ Concurrency in Practice

Course: C++ Standard Library including C++14 & C++17

Course: Embedded Programming with Modern C++

Course: Generic Programming (Templates)

Course: C++ Fundamentals for Professionals

Interactive Course: The All-in-One Guide to C++20

Subscribe to the newsletter (+ pdf bundle)

Blog archive

Source Code

Visitors

Today 7227

Yesterday 7224

Week 29226

Month 34491

All 6892700

Currently are 161 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments