-
Notifications
You must be signed in to change notification settings - Fork 1
Next lib version #3
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
base: master
Are you sure you want to change the base?
Conversation
| constexpr void operator()(object_t & aObject, acceptor_t & aAcceptor) const { | ||
| (*m_invokerPtr)(aObject, m_tag, aAcceptor); | ||
| } | ||
| constexpr void operator()(object_t* aObject, acceptor_t & aAcceptor) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't just call the 1st overload?
Like
constexpr void operator()(object_t * aObject, acceptor_t & aAcceptor) const {
assert(aObject && "No object");
(*this)(*aObject, aAcceptor);
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some time we get ref, some time get ref to pointer. So overload is simplest solve problem. In another cases necessary change code in many places as i think. maybe i'm wrong, but i have question. You try checkout last version and use your suggestion? Code complile and work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello sorry for this delay:)
The ref to a pointer has another meaning, ref to a pointer means that you'd like to "sync" changes to the address stored inside the pointer inside and outside the function/unit.
Here we're interesing only in accessing object's method.
And having an overload, which accepts pointer, means that we MUST think of it, since pointers may be NULL. So you MUST write "if (p != nullptr)" every time to avoid UB.
From these points it's safer just to not have public API, which accepts pointer at all.
Just use a reference.
| using compare_obj_t = std::remove_const_t<std::remove_pointer_t<Obj>>; | ||
| static_assert(std::is_same_v<std::remove_const_t<class_t>, compare_obj_t>, "must be one type"); | ||
|
|
||
| (obj->*aFx)(conditionalAddressOf<std::tuple_element_t<Idx, qalified_t>>(std::get<Idx>(tuple))...); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See not any check that obj is not nullptr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I will fix. But better exception as i think. If all ok exception will be cheap.
I think, I'll add gtest into the library. |
|
Maybe it will be easier to exchange Skype or somehow cooperate? Russian is our native language, we will understand each other faster |
This branch is almost end of common lib work.
Now need better error messages.
Think about better test organization.
Also some functions can be called more times then need.
Also i checked with valgrind. No memory leaks now.