File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 66#include < stacktrace>
77#include < type_traits>
88
9+ // library developers and advanced users may appreciate compiler checks to ensure they are actually
10+ // handling all errors.
11+ // By defining EXPLICIT_RESULTS, the Result conversion operators will be marked as explicit.
12+ // This does not break ABI, so libraries/projects dependencies can define EXPLICIT_RESULTS or not
13+ // and still be compatible.
14+ #ifndef EXPLICIT_RESULTS
15+ #define RESULT_EXPLICIT_QUALIFIER
16+ #else
17+ #define RESULT_EXPLICIT_QUALIFIER explicit
18+ #endif
19+
920namespace zest {
1021
1122template <typename T>
@@ -67,11 +78,11 @@ class Result {
6778 error({type, std::format (fmt, std::forward<Args>(args)...), std::stacktrace::current ()}) {
6879 }
6980
70- operator T () const & {
81+ RESULT_EXPLICIT_QUALIFIER operator T () const & {
7182 return val;
7283 }
7384
74- operator T () && {
85+ RESULT_EXPLICIT_QUALIFIER operator T () && {
7586 return std::move (val);
7687 }
7788
You can’t perform that action at this time.
0 commit comments