|
Boost : |
Subject: Re: [boost] [Safe Numerics] Review
From: Peter Dimov (lists_at_[hidden])
Date: 2017-03-12 14:54:06
John Maddock wrote:
> 5) What is the purpose of class safe_literal? constepxr initialization
> seems to work just fine without it?
The idea, I believe, is that if you have
safe_signed_range<0, 100> x;
and then you do
auto y = x * safe_signed_literal<2>();
you get safe_signed_range<0, 200> as the type of y. This could probably be
made less elaborate with a user-defined literal, for example
auto y = x * 2_sf;
or something like that.
Since x is not constexpr, it's not possible (I think) to achieve this result
without using a separate literal type to hold the compile-time constant 2.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk