constexpr

constexpr and consteval Functions in C++20

With C++20, constexpr became way more powerful. Additionally, we have  consteval functions in C++20 that are quite similar to constexpr functions.

Read more
Views: 15197

constexpr Functions

Today, I continue my story about programming at compile time. After template metaprogramming, the type-traits library, today's topic is constexpr functions in particular.

Read more
Tags: constexpr
Views: 17335

constexpr std::vector and std::string in C++20

Probably the most viral keyword in modern C++ is constexpr. With C++20, we have a constexpr std::vector and a constexpr std::string. Additionally, both containers can be manipulated with the constexpr algorithms of the Standard Template Library. 

Read more
Views: 77338

volatile and Other Small Improvements in C++20

Today, I complete my tour through the C++20 core language features with a few small improvements. One interesting of these minor improvements is that most of volatile has been deprecated.

Read more
Views: 22486

C++ 20: The Core Language

My last post C++20: The Big Four started with an overview of concepts, ranges, coroutines, and modules. Of course, C++20 has more to offer. Today, let's continue my overview of the core language.

Read more
Views: 159460

C++ Core Guidelines: Programming at Compile Time with constexpr

My mini-series about programming at compile time started with template metaprogramming, continued with the type-traits library, and ended today with constant expressions (constexpr).

Read more
Tags: constexpr
Views: 81817

Immutable Data

A key to purely functional languages is that their data are immutable. Therefore, assignments such as x= x+1 or ++x are not possible in the purely 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
Views: 28527

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 calculation result is at runtime as a constant in ROM available. In addition, constexpr functions are implicitly inline.

Read more
Tags: constexpr
Views: 87510

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 to evaluate at compile time.

 

Read more
Tags: constexpr
Views: 43374

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 evaluated at compile-time are done with their work at run time.

Read more
Tags: constexpr
Views: 19778

Stay Informed about my Mentoring

 

Mentoring

English 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

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

Course: Master Software Design Patterns and Architecture in C++

Subscribe to the newsletter (+ pdf bundle)

All tags

Blog archive

Source Code

Visitors

Today 3391

Yesterday 5555

Week 33599

Month 55273

All 12133482

Currently are 205 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments