Boost logo

Boost :

Subject: Re: [boost] [system] virtual ~error_category
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2018-02-12 23:29:51


>> Ok, cool. For the record, proposed `status_code` is templated and thus
>> can carry arbitrary payload, thus solving that problem in `error_code`.
>
> Bear in mind that templating can itself be a barrier to usage,
> especially when people want to keep implementation in cpp files rather
> than making everything into templates.
>
> (I'm not saying that templating is the wrong choice, but this was
> probably one of the motivations for current error_code not being a
> template.)

Both status_code and status_code_domain come in type erased and
templated forms. If you use the templated form, the optimiser eliminates
all runtime overhead in recent GCCs and clangs, even down to eliminating
instantiating the domain singleton because it's a constexpr variable. If
you use the type erased form, you do incur the indirect branch overhead
unless you turn on LTO.

So, you're covered.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

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