Namespaces
Variants
Views
Actions

Talk:cpp/error/error code

From cppreference.com
< Talk:cpp‎ | error
Revision as of 03:36, 20 October 2023 by BenFrantzDale (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

[edit] Vs std::error_condition?

This page really needs some explanation of when to use std::error_code vs std::error_condition. I know: "not portable" vs. "portable", but that's really not enough. BenFrantzDale (talk) 04:28, 20 October 2023 (PDT)

[edit] Customization point

This page (and by symmetry, std::error_condition really should clearly articulate the intend usage for customization. As I understand it, if I have an enum that I want to interoperate with std::error_code, I should provide template <> struct std::is_error_code_enum<MyEnum> : std::true_type {}; in the root namespace, and provide an ADL-accessible overload of make_error_code(MyEnum) (i.e., typically in MyEnum's namespace or possibly in ::std). That doing those two things makes std::error_code implicitly constructible from MyEnum. Is that right? BenFrantzDale (talk) 04:28, 20 October 2023 (PDT)