Mission Impossible / How to create datatypes which cannot contain invalid state


Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content
Next: Enums - Overview

Create datatypes which do not allow invalid state

Many user defined datatypes created in "classical" C++ allow many states which should not happen in production.

This playground has the goal to show some of them and how to avoid them using C++14/17 standard library type additions.

The build environment is:

  • Clang 7.0.1
  • -std=c++17
  • -Wall -Werror
  • Libraries: Boost 1.68


This playground was written for a C++ Usergroup session (https://cpp-ug-luzern.blogspot.com/). It may not yet be ready to use without further context.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content