Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-10-19 12:27:39


Rainer Deyke wrote:
> On 19.10.21 08:26, Gavin Lambert via Boost wrote:
> > Header-only does not avoid ABI ODR problems. It just moves where they
> > occur (which in some ways makes them a lot worse than built libraries).
>
> ODR violations can be prevented with namespace aliases.
>
> #if __cplusplus >= 201703L
> #define BOOST_JSON_NAMESPACE json_with_std_string_view
> namespace BOOST_JSON_NAMESPACE {
> using string_view = std::string_view;
> }
...

JSON already does that for its "standalone" mode, to support linking
"Boost" and "standalone" JSON in the same application because of
user demand.

> That said, compiling parts of the same program with different C++
> standards is asking for trouble. I would expect ODR violations from the
> standard library in that case.

People do that every day, sometimes without even realizing it.


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