rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.11k stars 429 forks source link

How to register int[] property in a struct? #346

Open Linhuihang opened 1 year ago

Linhuihang commented 1 year ago
#include <rttr/registration>

struct MyStruct { MyStruct() {}; int data[3]; };

RTTR_REGISTRATION
{
    using namespace rttr;

    registration::class_<MyStruct>("MyStruct")
      .constructor<>()
      .property("data", &MyStruct::data);
}

int main() {
    return 0;
}

Compile error: error C2668: 'operator new[]': ambiguous call to overloaded function

btgoodwin commented 1 year ago

For one thing, your MyStruct needs RTTR_ENABLE(); in the declaration:

struct MyStruct {
  MyStruct() {}
  int data[3];

  RTTR_ENABLE();
};
lyd405121 commented 10 months ago