entt icon indicating copy to clipboard operation
entt copied to clipboard

meta: data function fails if setter is noexcept

Open mathisloge opened this issue 1 year ago • 4 comments
trafficstars

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

mathisloge avatar Aug 17 '24 12:08 mathisloge

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.

skypjack avatar Aug 20 '24 12:08 skypjack

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.

skypjack avatar Aug 20 '24 12:08 skypjack

Hi,

I've tested it and it works now as expected. Thanks for fixing this so fast! :)

mathisloge avatar Aug 20 '24 15:08 mathisloge

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.

skypjack avatar Aug 20 '24 17:08 skypjack