constexpr

Immutable Data

A key to pure functional languages is that their data are immutable. Therefore, assignments such as x= x+1 or ++x are not possible in the pure functional language Haskell. The consequence is that Haskell supports no loops like for, while, or until. They are based on the modification of a loop variable. Haskell does not modify existing data; Haskell creates new data when needed and reuses the old ones.

Read more
Tags: constexpr
Comments 56Views: 3764

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 implicit inline.

Read more
Tags: constexpr
Add CommentViews: 3167

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
Comments 7Views: 2720

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
Comments 2Views: 1809

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
Comments 45Views: 2445

Thread-Safe Initialization of Data

In case the data is not modified when shared between threads, the story is simple. The data has only to be initialized in the thread safe way. It is not necessary to use an expensive lock for each access.

Read more
Comments 6Views: 3144

My Newest E-Books

Latest comments

Subscribe to the newsletter (+ pdf bundle)

Blog archive

Source Code

Visitors

Today 762

All 386353

Currently are 185 guests and no members online