|
Boost : |
From: Rainer Deyke (rdeyke_at_[hidden])
Date: 2021-10-19 11:12:50
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;
}
#else
#define BOOST_JSON_NAMESPACE json_with_boost_string_view
namespace BOOST_JSON_NAMESPACE {
using string_view = boost::string_view;
}
#endif
using json = BOOST_JSON_NAMESPACE;
namespace BOOST_JSON_NAMESPACE {
// Library contents go here.
}
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.
-- Rainer Deyke (rainerd_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk