MetaStuff icon indicating copy to clipboard operation
MetaStuff copied to clipboard

Can't declare member of array type

Open erunehtar opened this issue 7 years ago • 8 comments

If we do:

struct foo {
    float data[16];
};

namespace meta {
    template <> inline auto registerMembers<foo>() {
        return members(member("data", &foo::data));
    }
}

we get compile error function returns array because of the Member::getCopy function that returns by value.

Is there any template magic that can be done to disable this function (and all dependent calls) ?

Thank you, and nice job for this library!

erunehtar avatar Jul 17 '18 14:07 erunehtar

Hello. I'll take a look at it soon, pretty sure it can be fixed with some SFINAE. :)

eliasdaler avatar Jul 18 '18 14:07 eliasdaler

As a temporary workaround - std::array<float, 16> data works well. Looking for a proper fix at the moment.

eliasdaler avatar Jul 21 '18 12:07 eliasdaler

Can't fix this limitation easily - a lot of stuff needs a rewrite, so I can't promise a fix soon. :(

eliasdaler avatar Jul 27 '18 08:07 eliasdaler

Ok thanks for looking into this. For the moment I can just comment out the function since I don't need to access members by copy.

erunehtar avatar Jul 31 '18 14:07 erunehtar

Just an FYI, std::array didn't work for me, I had to swap to a vector, reserving the size. (Using MSVC C++20).

nhold avatar Oct 24 '20 06:10 nhold

Hello I'm surprised that someone still uses this library, haha.

eliasdaler avatar Oct 25 '20 11:10 eliasdaler

Why, don't you still use it?

nhold avatar Oct 25 '20 12:10 nhold

I don't. I think it's still useful, but I just didn't use it very much in my engine and decided that straightforward serialization/deserialization functions are easier to read/write. If your function have a lot of members and you need to serialize tons of types into multiple different formats, then it'll be quite useful still, indeed.

eliasdaler avatar Oct 25 '20 21:10 eliasdaler