|
Boost : |
From: Klemens Morgenstern (klemensdavidmorgenstern_at_[hidden])
Date: 2024-11-19 10:26:25
On Tue, Nov 19, 2024 at 6:13â¯PM Alexander Grund via Boost <
boost_at_[hidden]> wrote:
> >> maybe a related question - how to you handle overflows - for example
> >> reading a too large value into a float?
> > That's not supported, you'll need to provide a double or a 64 bit int.
> What do you mean by "not supported"? What happens when you read a value
> larger than INT_MAX to an int? Or a value exceeding FLOAT_MAX but still
> using a float?
> Will those be silently truncated, UB in case of int, wrapped to inf for
> float?
>
It won't compile. You can't read into an `int` implicitly.
Haven't checked yet, but I guess reading an int value to a string will
> cause an error/exception to be generated by the library, doesn't it?
> I'd argue the same should be done if the value doesn't fit in the
> numeric target type
>
No, you can freely convert as much as you want. sqlite is not strictly
typed.
Ideally you'd check the type beforehand.
> >> is there a way to define how safe the conversion should be (plain cast,
> >> check for overflow and throw exception)?
> >>
> > It's a minimal set of types at the moment and these are all safe.
> > A user can add his own conversions and will then be responsible to assure
> > it's safe.
> See above: In which way are they "safe"? Is this in the documentation?
>
> Truncating doesn't compile, but conversions do, following sqlite rules.
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk