entt
entt copied to clipboard
meta: data function fails if setter is noexcept
Given the following code
struct Test
{
public:
int x() const
{
return x_;
}
void setX(int newx) noexcept
{
x_ = newx;
}
private:
int x_;
};
entt::meta<Test>().data<&Test::setX, &Test::x>("x"_hs); // won't compile
If void setX(int newx) is noexcept(true) the using args_type = entt::meta_function_helper_t<Test, decltype(&Test::setX)>::args_type; can't resolve the arguments from setX, since somehow the get_rid_of_noexcept doesn't work.
As soon as I remove the noexcept, the code compiles again.
entt version: 3.13.2
It was harder to figure it out than to fix it. Good catch!
The issue is due to the support for member objects. That overload of get_rid_of_noexcept should only be conditionally enabled. Otherwise, it's a better match than the one where decaying the function type is required.
A fix is available on the wip branch. Can you confirm that it solves your issue?
The snippet above works fine with it. Not sure if the same applies to your real world case though.
Thanks.
Hi,
I've tested it and it works now as expected. Thanks for fixing this so fast! :)
Thanks for pointing it out. It was a subtle issue actually. I'll include the fix in the upcoming minor release rather than making a new patch release.