Comments (5)
Apologies for not keeping the documentation up to date
The supported number of struct members is limited, with the default limit set at 32. If you wish to support a greater number, simply run generate.py and pass the -f <count>
flag, where count is the maximum number you want to support. For example:
python generate.py -f 64
This will enable support for structs with up to 64 members. The resulting code can be found in the files include/magic/struct_bind_of_field_types.ge
and include/magic/struct_bind_of_field_names.ge
. You can check these files to ensure that the changes have taken effect.
from magic-cpp.
struct Test
{
int a;
int a1;
int a2;
int a3;
int a4;
int a5;
int a6;
int a7;
int a8;
int a9;
int a10;
int a11;
int a12;
int a13;
int a14;
int a15;
int a16;
int a17;
int a18;
int a19;
int a20;
int a21;
int a22;
int a23;
int a24;
int a25;
int a26;
int a27;
int a28;
int a29;
int a30;
int a31;
int a32;
int a33;
int a34;
int a35;
int a36;
int a37;
int a38;
int a39;
int a40;
int a41;
int a42;
int a43;
int a44;
int a45;
int a46;
int a47;
int a48;
int a49;
int a50;
int a51;
int a52;
int a53;
int a54;
int a55;
int a56;
int a57;
int a58;
int a59;
int a60;
int a61;
int a62;
int a63;
int a64;
int a65;
int a66;
int a67;
int a68;
int a69;
int a70;
int a71;
int a72;
int a73;
int a74;
int a75;
int a76;
int a77;
int a78;
int a79;
int a80;
int a81;
int a82;
int a83;
int a84;
int a85;
int a86;
int a87;
int a88;
int a89;
int a90;
int a91;
int a92;
int a93;
int a94;
int a95;
int a96;
int a97;
int a98;
int a99;
int a100;
int a101;
int a102;
int a103;
int a104;
int a105;
int a106;
int a107;
int a108;
int a109;
int a110;
int a111;
int a112;
int a113;
int a114;
int a115;
int a116;
int a117;
int a118;
int a119;
int a120;
int a121;
int a122;
int a123;
int a124;
int a125;
int a126;
int a127;
};
I tried to do this. When the number of members reaches 122, the compiler will prompt "block nesting is too deep"
from magic-cpp.
Maybe supporting an specialization for your struct will be fine
namespace magic
{
template<>
struct type_info<Test>
{
constexpr static auto count = 128;
};
}
the error occurs because of this C1061
Besides, you can also just use GCC or Clang.
from magic-cpp.
C1061 still exists. Maybe you can try it. I use MSVC compiler
namespace magic
{
template<>
struct type_info<Test>
{
constexpr static auto count = sizeof(Test) / sizeof(int);
};
}
int main()
{
auto f = [](auto field)
{
constexpr auto name = field.name();
std::cout << name << std::endl;
};
magic::foreach(Test{}, f);
getchar();
return 0;
}
from magic-cpp.
In fact, it can work in my environment: MSVC 19.38. But what is interesting is that if I don't provide a specialization for it, the error C1060: the compiler does not have enough heap will be emitted. If not, it will just compile, although slowly. But without a doubt, too many templates are too hard to handle for MSVC; you would be better off splitting your struct into smaller parts.
from magic-cpp.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magic-cpp.