-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Friend declaration of indirecting_domain
& nested_status_code/status_code_ptr in single header version
#58
Comments
edition. Also fix incorrect friend declaration.
I fixed the other two. Can you explain more this one?
|
Cool! And yeah regarding the first one, let's say we have
I think this is because most of the
But |
Well, status-code/include/status-code/status_code_domain.hpp Lines 104 to 107 in 2086daf
I.e. we can remove the need for friend declarations in every domain type by upcasting to diff --git a/include/status-code/nested_status_code.hpp b/include/status-code/nested_status_code.hpp
--- include/status-code/nested_status_code.hpp
+++ include/status-code/nested_status_code.hpp
@@ -101,9 +101,10 @@
virtual bool _do_equivalent(const status_code<void> &code1, const status_code<void> &code2) const noexcept override // NOLINT
{
assert(code1.domain() == *this);
const auto &c1 = static_cast<const _mycode &>(code1); // NOLINT
- return typename StatusCode::domain_type()._do_equivalent(c1.value()->sc, code2);
+ typename StatusCode::domain_type foreignDomain{};
+ return static_cast<status_code_domain &>(foreignDomain)._do_equivalent(c1.value()->sc, code2);
}
virtual generic_code _generic_code(const status_code<void> &code) const noexcept override // NOLINT
{
assert(code.domain() == *this);
I've put a minimal demonstrator on godbolt |
@BurningEnlightenment beat me to writing that comment. Thanks! Is this issue now fully addressed? |
Yeah thanks both of you! |
Thanks for reporting it! |
No, derived domains still need to explicitly befriend the I wanted to submit a PR, but didn't get to it |
Hi again!
I was trying to follow the docs from https://ned14.github.io/outcome/experimental/worked-example/implicit_conversion/ to create a status code with a
value_type
bigger than anintptr_t
. A couple thingsVery possibly I'm missing something, but it seems that using
make_nested_status_code
(ormake_status_code_ptr
in the old version) requires afriend
declaration fordetail::indirecting_status_domain
--maybe this should be documented?I believe the
friend
declaration may be misspelled in the abstract base class here? There is nodetail::
namespace as there is forposix_code
,generic_code
, etc.status-code/include/status-code/status_code_domain.hpp
Line 107 in 6bd2d56
status-code/include/status-code/posix_code.hpp
Line 78 in 6bd2d56
This just came up incidentally when trying to isolate my compile error on godbolt, but it looks like the single header version does not include the
indirecting_domain
stuff. I notice that the single-header readme still refers tostatus_code_ptr.hpp
, but there is no mention ofmake_status_code_ptr
ormake_nested_status_code
in any of the generated headers.All the best
The text was updated successfully, but these errors were encountered: