Arithmetic (opaque) type without implicit conversions

Arithmetic<T, U = void> is a type that: - models the Arithmetic concept, - wraps a T that also models the arithmetic concept, and - can be used as a strong/opaque typedef for T. It is thus similar to Boost.Serialization's BOOST_STRONG_TYPEDEF, - but without any implicit conversions (only explicit ones), and - it supports move semantics and C++14 constexpr. The code is here: https://github.com/gnzlbg/arithmetic_type The Readme.md is brief, so I refer you to there for more information. There are also some tests, although it could use some more. The LoungeC++ and Morwen@codereview.stackexchange deserve credit for some improvements on the implementation. The remaining mistakes are only mine. So please, destroy my implementation if you find any mistakes. I find it useful to strongly type interfaces that involve indices, e.g. in an octree implementation where child/neighbor indices for a node with different types result in clear compilation errors if mixed. I hope you find it useful too. Bests, Gonzalo BG
participants (1)
-
Gonzalo BG