C++ Logo


Advanced search

Subject: Re: [std-proposals] add "numeric_cast" to <numeric> header
From: Charles Milette (charlesmilette_at_[hidden])
Date: 2020-05-15 18:19:58

See also: gsl::narrow and wil::safe_cast

On Fri, May 15, 2020 at 7:09 PM Qingfeng Xia via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> Dear all,
> I hope runtime safe `numeric_cast` can be added to standard library header <numeric>.
> The boost library has already got such feature, I wonder if there is already a proposal to merge it into the next standard?
> Before I searched and reached Boost::numeric_cast, I reinvented the wheel, together with some other helper functions. More technical details are written in markdown at:
> https://github.com/qingfengxia/cpp_numeric_cast/blob/master/proposal_numeric_cast.md
> I have another idea: reuse the `explicit` keyword to prevent implicit conversion of function parameter. https://github.com/qingfengxia/cpp_numeric_cast/blob/master/proposal_explicit.md I am not sure it is the correct maillist to discuss this idea. It proposes to change compiler code-base/hehaviors. Please advise, shall I send another email somewhere else for this idea?
> Demo code and implementation are hosted at: https://github.com/qingfengxia/cpp_numeric_cast
> Both ideas are at the "Float the idea" stage, all the code and text are in early draft condition. They will be update and improve gradually.
> Thank you and looking forwards to feedback.
> Yours Sincerely,
> Qingfeng Xia
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups