What is the Arithmetic concept?
Types that supports all operations provided by integral and floating point
types "model" the Arithmetic "constraint" (better than the word concept in
this context), as checked by std::is_arithmetic<T> [0], which is defined as
std::is_integral<T> || std::is_floating_point<T>.
I don't static_assert(std::is_arithmetic<T>) to allow other types that
might be viable but for which there is not a specialization of
std::is_integral/std::is_floating_point.
[0] http://en.cppreference.com/w/cpp/types/is_arithmetic
On Tue, Mar 18, 2014 at 5:38 PM, Robert Ramey wrote: On Tuesday, March 18, 2014 8:42:02 AM UTC-7, Gonzalo BG wrote: Arithmetic What is 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 _______________________________________________
Unsubscribe & other changes: http://lists.boost.org/
mailman/listinfo.cgi/boost