Boost logo

Boost :

Subject: Re: [boost] [system] A non-allocating message() overload
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-09-19 18:38:35

On 9/19/18 8:56 PM, Peter Dimov via Boost wrote:
> One of the objections against <system_error> is that message() needs to
> allocate memory, because it returns an std::string. This is true even
> for user-defined categories that can implement it without allocating,
> with a static message table.
> To address this, I'm thinking of adding the following overload to
> boost::system::error_category (with the intent of proposing it for
> std::error_category):
>    virtual char const* message( int ev, char* buffer, size_t len )
> noexcept;
> This is modeled after the glibc-specific version of strerror_r (and in
> fact has the exact same signature and behavior). If the implementation
> has a static character literal corresponding to `ev`, it returns it
> directly. If not, it composes an error message into the provided buffer,
> then returns `buffer`.
> Comments?

I like the idea, but what about platforms that don't have strerror_r?
noexcept means that the new overload cannot be implemented atop the
standard one (e.g. one can't forward the call to the current

Boost list run by bdawes at, gregod at, cpdaniel at, john at