ice icon indicating copy to clipboard operation
ice copied to clipboard

Replace PropertyArray with std::array

Open pepone opened this issue 1 year ago • 1 comments

In PropertyNames.h we define PropertyArray:

struct PropertyArray
    {
        const Property* properties;
        const int length;

        PropertyArray(const Property* p, size_t len) : properties(p), length(static_cast<int>(len)) {}
    };

I think we should be able to replace this by std::array

pepone avatar Mar 28 '24 17:03 pepone

I tried to implement this. The issue is that std::array's size is part of the type, eg. std::array<int, 4>. Creating a nested std::array of different sized std::array's isn't possible (which is the case for our property arrays).

I saw a post on stack overflow that seems to work around this using std::span, but that isn't available to us as it requires c++20.

We could switch to using std::vector for everything but not sure that's really preferable. Thoughts?

externl avatar May 07 '24 18:05 externl

As mentioned by @externl using std::array doesn't work here, we can keep the current code.

pepone avatar May 17 '24 15:05 pepone