Boost logo

Boost :

From: Matt Borland (matt_at_[hidden])
Date: 2025-01-17 19:54:07


On Friday, January 17th, 2025 at 2:35 PM, Ruben Perez <rubenperez038_at_[hidden]> wrote:

>

>

> >
>

> > > > I never tried many of the permutations of headers outside of the convenience one. The library is structured to match the STL so that it is unsurprising to the average user. I think you could pick and choose if you wanted to.
> >

> > > I tried picking charconv and it didn't work :)
> >

> > > I think that the actual header structure is good, matching STL as you
> > > said. I don't agree with recommending users to always include the
> > > entire library - I think that increases compile times without much
> > > benefit. Hence I was asking whether there was an actual reason to do
> > > it.
> >

> > So there's things I have to manually set that most never worry about for builtin types like global rounding mode and float evaluation method. Some impl headers need forward declarations of the types, some don't. It's pretty convenient from a design perspective to make things just work with no effort on the part of the user. I'm sure everything could be made to work piecemeal, but for a difference of maybe 3 seconds of compile time it's not worth the effort.
>

>

> I'm afraid I don't agree here. Since this is a header-only library,
> this is 3 seconds added to both direct and indirect users of the
> library. If all Boost libraries did this, compile times would become
> unmanageable. Also, Boost doesn't have the best reputation in this
> aspect, so I think taking care of this is valuable.
>

> Having a set of public headers that work is established practice in
> Boost, and I'd advise to follow it.
>

> > > > > 3. In the line of the previous question, is there a reason to have
> > > > > BOOST_DECIMAL_DISABLE_IOSTREAM instead of splitting iostream
> > > > > functionality to a separate header? In my experience, the more config
> > > > > macros you have, the more chances of getting bugs. Also, is the test
> > > > > suite being run with these macros defined?
> >

> > > > We have a the options to disable a bunch of the clib functionality so that the library can run on embedded platforms. We do have QEMU of an STM board in the CI which tests all of this. Why test embedded you ask? It's not uncommon for finance devs to run on bare metal platforms.
> >

> > > I understand the objective, and I think it's great having tests for
> > > that. But I don't think the method is the best.
> >

> > > I've reviewed all uses of BOOST_DECIMAL_DISABLE_IOSTREAM, and if I'm
> > > reading this correctly, they all guard functions that are exclusively
> > > used in the tests. I don't think these functions should be in the
> > > headers shipped to users, but in the tests.
> >

> > > I acknowledge that these functions require access to private members
> > > of public classes, so I guess that's why they are defined there. I use
> > > a dummy friend struct placed in the detail namespace when I have such
> > > problems (I think I copied the pattern from Boost.Json). I think you
> > > can get rid of all the iostream includes altogether doing this (except
> > > for the ones in io.hpp, which are actually not guarded by the macro).
> >

> > > BOOST_DECIMAL_DISABLE_CLIB ifdefs-out entire headers - wouldn't it be
> > > simpler to have a subset of headers allowable in embedded systems,
> > > with others just labelled as "not supported"?
> >

> > The functions are only used in tests because they are for the end user. We have no need for streaming in the implementation. Since this is a header-only library I am not worried about library incompatibilities from different configurations.
>

>

> I think we might be talking about different things here. Grepping for
> BOOST_DECIMAL_DISABLE_IOSTREAM, it protects the following functions:
>

> * debug_pattern: not documented and excluded from coverage
> * bit_string: not documented
> * Streaming native/emulated, signed/unsigned 128/256 integer types,
> all of which are in namespace detail.
>

> Is the end user expected to use any of these?
>

No, but if you define BOOST_DECIMAL_DISABLE_CLIB like you previously mentioned it defines for you BOOST_DECIMAL_DISABLE_IOSTREAM (if not already defined). The guard in detail/io.hpp should be the latter instead of the former for consistency as detailed in the docs. We use BOOST_DECIMAL_DISABLE_CLIB in the metal CI.

Matt






Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk