Boost logo

Boost :

Subject: Re: [boost] [system] Header-only Boost.System by default ?
From: Damien Buhl (damien.buhl_at_[hidden])
Date: 2017-10-10 07:18:13


On 09/10/2017 19:34, Niall Douglas via Boost wrote:
>> Is there any reason why Boost system couldn't be set to be header only
>> by default ?
[...]
> The only correct and safe way to use error categories is from a shared
> library. In header only mode, multiple instances may appear and thus no
> longer be proper singletons. Stuff breaks in this situation, badly.

If I implement an error category of my own like this :

```cpp

  inline const basic_error_category& get_basic_error_category() {
    static basic_error_category category{};
    return category;
  }

  static const boost::system::error_category& basic_error_category =
get_basic_error_category();

```

Is there really no guarantee that category always get the same address
across TUs ?

It has been my understanding of extern inline linkage that it actually
is so.
The linker keeps only one copy in the final program. In C++17 we could
even use the static inline specifier for variables.

Cheers,

-- 
Damien Buhl

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