Boost logo

Boost :

Subject: Re: [boost] [system] Would it be possible to trial a breaking change to Boost.System and see what happens?
From: Peter Dimov (lists_at_[hidden])
Date: 2018-01-15 00:21:30


Niall Douglas wrote:

> I am bothered about the approx 2 seconds per compiland that including
> <string> adds if no other STL is being included. In a million file
> codebase, that's an extra 23 days of compute time per build. It's
> unacceptable.

<system_error> doesn't need to include <string>. A forward declaration is
enough. User code that calls message() does need to include <string> of
course.

// <system_error>

template<class E> class char_traits;
template<class T> class allocator;
template<class E, class T = char_traits<E>, class A = allocator<E>> class
basic_string;
typedef basic_string<char> string;

class error_category
{
public:

    virtual string message( int ev ) const = 0;
};

error_category const& system_category();

class error_code
{
private:

    int e_;
    error_category const* p_;

public:

    error_code() noexcept: e_(0), p_(&system_category()) {}
    string message();
};

// <string>

template<class E, class T, class A> class basic_string
{
};

// user code

int main()
{
    error_code().message();
}

We can't do this in Boost.System because it's not possible to
forward-declare std::string portably, but the standard library can.

Incidentally, have you measured the inclusion time of <string_view>?


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