What is the maximum number of elements I can put in BOOST_HANA_ADAPT_STRUCT

60 Views Asked by At

When there are fewer elements in BOOST_HANA_ADAPT_STRUCT, such as 30 elements, there is no problem in compilation. But once it exceeds a certain number, the compilation prompts errors about every field within the BOOST_HANA_ADAPT_STRUCT has not been declared.

i'm using g++17 and boost 1.74. i'm not sure is there parameter to set to sort it out. say, i might need to put around 100 fields in the BOOST_HANA_ADAPT_STRUCT.

an example failure case as below,

#define BOOST_HANA_CONFIG_ENABLE_STRING_UDL 1
#define BOOST_HANA_CONFIG_ADAPT_STRUCT_MAX_ARITY 50
#include <boost/hana.hpp>
struct my_struct {
    int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q,r,s,t;
    char  aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp,qq,rr,ss,tt;
};

BOOST_HANA_ADAPT_STRUCT(my_struct,
    a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q,r,s,t,
    aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp,qq,rr,ss,tt
);
int main() {
  return 0;
}

as soon as the number of elements reaches 40, it fails compiling unless i remove some elements.

1

There are 1 best solutions below

2
273K On

As for the boost/hana/detail/struct_macros.hpp:1462 the limit is 55 member variables.

#define BOOST_HANA_ADAPT_STRUCT_IMPL_56(TYPE , m1, m2, ..., m54, m55)    \