Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-01-25 00:14:59


Matt Borland wrote:
> > Would it be too hard to provide a header-only way of consuming this
> library?
> > Libraries like Boost.Test allow that, but I do not know how that
> > squares with ODR.
> >
>
> > Regards,
> > &rzej;
> >
>
>
> I have not looked into it, but I assume it's possible because other libraries do it.
> Opened: https://github.com/cppalliance/charconv/issues/136 to track the
> issue.

To repeat what I said in a comment on the issue, this is not a good idea, at all.

"Optional" header-only mode doesn't work well for libraries whose primary
purpose is to be used by other libraries. As an example, suppose JSON wants
to use Charconv; it now has to decide whether to use it header-only, or
compiled. But then suppose that a project uses JSON and another library that
uses Charconv, or Charconv directly; all of these dependencies MUST pick the
same mode of "consuming" Charconv, and you don't really have any control
over that.

"Optional" header-only modes create nothing but trouble. Pick one "mode"
and stick with it. (And, while header-only may superficially be more convenient,
it's not quite the right fit for libraries with, e.g. large lookup tables.)


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