Custom template type class: strong_typedef

Photo by Just Software Solutions

Start 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,..."

Read more on the site

View Article

More info
#18th in TOP Native articles
Level N/A

Author

Added by: Jack
Report article