boostorg / leaf

Lightweight Error Augmentation Framework
Boost Software License 1.0
313 stars 48 forks source link

Leaf should document whether specializing `leaf::match` is allowed #9

Closed steveire closed 4 years ago

steveire commented 4 years ago

It is possible to specialize match in order to match on properties of error types other than .value.

Consider that this makes it possible to match on the category of a std::error_code, but this should be possible for any user-defined error type:

https://godbolt.org/z/YRXTtZ

It should be documented whether this kind of specialization of matching is allowed.

zajo commented 4 years ago

The match<> api is currently overloaded but I have already changed that in my working branch. Now there will be several separate predicates: match<>, match_value<> (which matches on .value), match_member<> (which can match any data member, but requires C++17).