Subject: [boost] Arithmetic (opaque) type without implicit conversions
From: Gonzalo BG (gonzalobg88_at_[hidden])
Date: 2014-03-18 11:42:02
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_at_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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk