Here is the code:
`#include <alpaca/alpaca.h>
struct StartPacket
{
int32_t byteCount;
char magic[4];
};
int main()
{
StartPacket startPacket;
std::vector<uint8_t> buffer;
auto size = alpaca::serialize(startPacket, buffer);
return 0;
}
`
and here is the compilation error:
In file included from thirdparty/alpaca/include/alpaca/alpaca.h:9, from serialise.cpp:1: thirdparty/alpaca/include/alpaca/detail/struct_nth_field.h: In instantiation of ‘constexpr decltype(auto) alpaca::detail::get(type&) [with long unsigned int index = 0; type = const StartPacket&; long unsigned int arity = 5]’: thirdparty/alpaca/include/alpaca/alpaca.h:137:60: required from ‘void alpaca::detail::serialize_helper(const T&, Container&, std::size_t&) [with alpaca::options O = alpaca::options::none; T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; long unsigned int I = 0; std::size_t = long unsigned int]’ thirdparty/alpaca/include/alpaca/alpaca.h:169:62: required from ‘std::size_t alpaca::serialize(const T&, Container&) [with T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; std::size_t = long unsigned int]’ serialise.cpp:13:54: required from here thirdparty/alpaca/include/alpaca/detail/struct_nth_field.h:54:11: error: 5 names provided for structured binding 54 | auto &[p1, p2, p3, p4, p5] = value; | ^~~~~~~~~~~~~~~~~~~~ thirdparty/alpaca/include/alpaca/detail/struct_nth_field.h:54:11: note: while ‘const StartPacket’ decomposes into 2 elements In file included from serialise.cpp:1: thirdparty/alpaca/include/alpaca/alpaca.h: In instantiation of ‘void alpaca::detail::serialize_helper(const T&, Container&, std::size_t&) [with alpaca::options O = alpaca::options::none; T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; long unsigned int I = 0; std::size_t = long unsigned int]’: thirdparty/alpaca/include/alpaca/alpaca.h:169:62: required from ‘std::size_t alpaca::serialize(const T&, Container&) [with T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; std::size_t = long unsigned int]’ serialise.cpp:13:54: required from here thirdparty/alpaca/include/alpaca/alpaca.h:137:20: error: ‘void field’ has incomplete type 137 | decltype(auto) field = detail::get<I, decltype(ref), N>(ref); | ^~~~~
This seems like a bug to me. This is with the latest alpaca code via git clone as of 2024-12-28.
Here is the code:
`#include <alpaca/alpaca.h>
struct StartPacket
{
int32_t byteCount;
char magic[4];
};
int main()
{
StartPacket startPacket;
std::vector<uint8_t> buffer;
auto size = alpaca::serialize(startPacket, buffer);
return 0;
}
`
and here is the compilation error:
In file included from thirdparty/alpaca/include/alpaca/alpaca.h:9, from serialise.cpp:1: thirdparty/alpaca/include/alpaca/detail/struct_nth_field.h: In instantiation of ‘constexpr decltype(auto) alpaca::detail::get(type&) [with long unsigned int index = 0; type = const StartPacket&; long unsigned int arity = 5]’: thirdparty/alpaca/include/alpaca/alpaca.h:137:60: required from ‘void alpaca::detail::serialize_helper(const T&, Container&, std::size_t&) [with alpaca::options O = alpaca::options::none; T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; long unsigned int I = 0; std::size_t = long unsigned int]’ thirdparty/alpaca/include/alpaca/alpaca.h:169:62: required from ‘std::size_t alpaca::serialize(const T&, Container&) [with T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; std::size_t = long unsigned int]’ serialise.cpp:13:54: required from here thirdparty/alpaca/include/alpaca/detail/struct_nth_field.h:54:11: error: 5 names provided for structured binding 54 | auto &[p1, p2, p3, p4, p5] = value; | ^~~~~~~~~~~~~~~~~~~~ thirdparty/alpaca/include/alpaca/detail/struct_nth_field.h:54:11: note: while ‘const StartPacket’ decomposes into 2 elements In file included from serialise.cpp:1: thirdparty/alpaca/include/alpaca/alpaca.h: In instantiation of ‘void alpaca::detail::serialize_helper(const T&, Container&, std::size_t&) [with alpaca::options O = alpaca::options::none; T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; long unsigned int I = 0; std::size_t = long unsigned int]’: thirdparty/alpaca/include/alpaca/alpaca.h:169:62: required from ‘std::size_t alpaca::serialize(const T&, Container&) [with T = StartPacket; long unsigned int N = 5; Container = std::vector<unsigned char>; std::size_t = long unsigned int]’ serialise.cpp:13:54: required from here thirdparty/alpaca/include/alpaca/alpaca.h:137:20: error: ‘void field’ has incomplete type 137 | decltype(auto) field = detail::get<I, decltype(ref), N>(ref); | ^~~~~This seems like a bug to me. This is with the latest alpaca code via git clone as of 2024-12-28.