Custom template type class: strong_typedef
C++ 29 May 2019 816Start using custom classes instead of build-in one for wrapping existing types and associates with a tag type to define the purpose and which then would make it unique. By wrapping primitive type of var in a unique type for each usage we can therefore eliminate this class of problem.
Declare types, create values and assecc the value with custom `strong_typedef` class definitions. Use it for IDs, Indexes and behavior class properties like `jss::strong_typedef_properties::hashable` or `jss::strong_typedef_properties::comparable` for example.
"One common problem in C++ code is the use of simple types for many things: a std::string might be a filename, a person's name, a SQL query string or a piece of JSON; an int could be a count, an index,..."
Author
Just Software Solutions
For further author's articles please visit the author's website.
https://www.justsoftwaresolutions.co.uk/