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 1Views: 2419

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: 1442

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 6Views: 1683

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: 926

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 5Views: 2116

Support my blog by buying my E-book

Latest comments

Modernes C++

Subscribe to the newsletter

Including two chapters of my e-book
Introduction and Multithreading

Blog archive

Source Code

Visitors

Today 2114

All 228128

Currently are 105 guests and no members online