pfr icon indicating copy to clipboard operation
pfr copied to clipboard

Is it possible to handle C arrays? Possible implementation linked

Open quicknir opened this issue 1 year ago • 8 comments

There's another library called repr which claims to handle C arrays properly: https://godbolt.org/z/vbz639n4d. Can this solution be used to handle C arrays properly in boost pfr?

Here's a link to the implementation as it appears in the source tree (rather than amalgamated): https://github.com/Tsche/repr/blob/master/include/librepr/reflection/detail/arity.h

quicknir avatar Sep 23 '24 15:09 quicknir

This defect was one of the reasons I wrote my own library :P

Related: https://github.com/boostorg/pfr/issues/16 https://github.com/boostorg/pfr/issues/20 https://github.com/boostorg/pfr/issues/162 https://github.com/boostorg/pfr/issues/169 https://github.com/boostorg/pfr/issues/170

Tsche avatar Sep 23 '24 18:09 Tsche

The fix in #170 works, I've tested it with giant multiply-nested structs

p00f avatar Sep 27 '24 10:09 p00f

Solution from #170 breaks multiple tests. It requires some additional tweaking, I'd appreciate a PR.

As a quick workaround you could replace native C array with std::array

apolukhin avatar Oct 17 '24 09:10 apolukhin

std::array is not an option because the structs containing the arrays are from headers i don't control

I'm willing to fix the tests but don't have much experience with template metaprogramming, would it be fine if I give it a try and you can guide me in the PR?

p00f avatar Oct 17 '24 09:10 p00f

Also, how do I run the tests?

p00f avatar Oct 17 '24 09:10 p00f

would it be fine if I give it a try and you can guide me in the PR?

Yes, I'll do my best

Also, how do I run the tests?

I usually checkout the whole Boost with submodules https://github.com/boostorg/boost

Then run the ./bootstrap.sh

After that

cd libs/pfr/test
../../../b2 cxxstd=17 toolset=clang-19

apolukhin avatar Oct 19 '24 13:10 apolukhin

cxxstd=17

don't you need 20 for this names_as_array and friends?

toolset=clang-19

my distro only has llvm 18

regardless, i'll try and see if this works

p00f avatar Oct 19 '24 13:10 p00f

https://github.com/boostorg/pfr/pull/189

p00f avatar Oct 19 '24 14:10 p00f