Boost logo

Boost :

Subject: Re: [boost] Arithmetic (opaque) type without implicit conversions
From: Gonzalo BG (gonzalobg88_at_[hidden])
Date: 2014-03-18 13:45:38

> 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


On Tue, Mar 18, 2014 at 5:38 PM, Robert Ramey <robertmacleranramey_at_[hidden]
> wrote:

> On Tuesday, March 18, 2014 8:42:02 AM UTC-7, Gonzalo BG wrote:
>> Arithmetic<T, U = void> is a type that:
>> - models the Arithmetic concept,
> 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:
>> The 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.
>> Bests,
>> Gonzalo BG
>> _______________________________________________
>> Unsubscribe & other changes:
>> mailman/listinfo.cgi/boost

Boost list run by bdawes at, gregod at, cpdaniel at, john at