rttrorg / rttr

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

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

Open Linhuihang opened 2 years ago

Linhuihang commented 2 years 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 1 year ago