ned14 / status-code

Proposed SG14 status_code for the C++ standard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default implementations of methods?

DaanDeMeyer opened this issue · comments

There's a lot of boilerplate associated with making new status codes. Especially for network protocol status codes that have nothing in common with generic_code, almost every domain is very similar:

  • All _generic_code implementations return errc::unknown.
  • All _do_equivalent implementations check for exact equality if the domains are equal and return false otherwise.
  • All _do_throw_exception implementations throw a status_error.

Is there any way to reduce this boilerplate? I thought about creating my own status_code_domain with default implementations but I don't know value_type there so I don't think that would work for _do_equivalent and _do_throw_exception.

You can of course create your own helper domain to reduce boilerplate. But whether that's worth standardising, I guess LEWG will say in Belfast.