What are customization point objects and how to use them?

What are customization point objects? They are function object instances in namespace std that fulfill two objectives: first unconditionally trigger (conceptified) type requirements on the argument(s), then dispatch to the correct function in namespace std or via ADL. In particular, why are they objects? That’s necessary to circumvent a second lookup phase that would directly … Read more

Why is volatile deprecated in C++20?

There’s a good talk by the C++ committee language evolution chair on why. Brief summary, the places that volatile is being removed from didn’t have any well defined meaning in the standard and just caused confusion. Motivating (Ambiguous) Examples Volatile bit Fields should be specified by your hardware manual and/or compiler. Is += a single/atomic … Read more

Class type non-type template parameter initialization does not compile

This template-argument {.a=1, .b=2} is not allowed according to the grammar for a template-argument which only allows the following constructs: template-argument: constant-expression type-id id-expression A brace-init list is not any of the above constructs, it’s actually an initializer and so it cannot be used as a template-argument. You can be explicit about the type of … Read more

Can class template constructors have a redundant template parameter list in c++20

There was a change, in fact. It’s documented in the compatibility section of the C++20 draft. [diff.cpp17.class] 2 Affected subclauses: [class.ctor] and [class.dtor] Change: A simple-template-id is no longer valid as the declarator-id of a constructor or destructor. Rationale: Remove potentially error-prone option for redundancy. Effect on original feature: Valid C++ 2017 code may fail … Read more

What is `constinit` in C++20?

What does constinit mean? Why was it introduced? In which cases should we use it? Initializing a variable with static storage duration might result in two outcomes¹: The variable is initialized at compile-time (constant-initialization); The variable is initialized the first time control passes through its declaration. Case (2) is problematic because it can lead to … Read more

Why does aggregate initialization not work anymore since C++20 if a constructor is explicitly defaulted or deleted?

The abstract from P1008, the proposal that led to the change: C++ currently allows some types with user-declared constructors to be initialized via aggregate initialization, bypassing those constructors. The result is code that is surprising, confusing, and buggy. This paper proposes a fix that makes initialization semantics in C++ safer, more uniform,and easier to teach. … Read more