Type Safe C++ enum Extensions -- Alf Steinbach
Is it possible to extend a value type in C++? Alf Steinbach describes how to extend enum values.
Type Safe C++ enum Extensions
by Alf Steinbach
From the article:
Consider if an
enumlike the following,enum class Suit{ spades, hearts, diamonds, clubs };could be extended like
enum class Suit_with_joker extends Suit { joker };where
Suit_with_jokerhas all the enumerators ofSuitplus thejokerenumerator; and- enumerators introduced in
Suit_with_jokerget integer values following those ofSuit; and- any
Suitvalue is also aSuit_with_jokervalue.This would be an example of what I’ll call a value type extension.
The apparently backwards is-a relationship in the last point, where any value of the original type is-a value of the derived type, is characteristic of value type extensions.
C++20 totally lacks support for value type extensions, of
enumtypes or other types.

Operator overloading. Looks great. Reduces verbosity. Until it doesn’t.
Guarded Suspension applies a unique strategy to deal with mutation. It signals when it is done with its modification.
Recently, our team at Meteksan Defense is upgrading its development environment to use newer versions of many tools and programming languages. One of the more difficult transitions has been the upgrade of our C++11 code base to C++17 for our embedded applications.
I continue my journey with concurrency patterns in today's post. The Thread-Safe Interface fits very well when the critical sections are just objects.
Fold expressions exist in C++ since C++17 and significantly affect how we treat variadic templates. Back in the day, I wrote about
Locking is a straightforward idea to protect a critical section. A critical section is a section of code that, at most, one thread can use at any time.