Skip to content

Conversation

@Lokimed
Copy link

@Lokimed Lokimed commented Feb 23, 2020

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.

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 {
Copy link
Member

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);
}

Copy link
Author

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?

Copy link
Member

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))...);
Copy link
Member

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.

Copy link
Author

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.

@alex-ganyukhin
Copy link
Member

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.

I think, I'll add gtest into the library.

@Lokimed
Copy link
Author

Lokimed commented Feb 24, 2020

Maybe it will be easier to exchange Skype or somehow cooperate? Russian is our native language, we will understand each other faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants