diff --git a/src/serialize19.lib/serialize19/serialize.Tuple.h b/src/serialize19.lib/serialize19/serialize.Tuple.h index 624b0a1..7eb86ac 100644 --- a/src/serialize19.lib/serialize19/serialize.Tuple.h +++ b/src/serialize19.lib/serialize19/serialize.Tuple.h @@ -5,8 +5,11 @@ namespace serialize19 { template void serialize(A& a, tuple19::Tuple& tuple) { + using meta19::nullptr_to; using meta19::type; - (serialize(a, tuple.amendOf(type)), ...); + [&](std::index_sequence*) { + (serialize(a, tuple.template amendAt()), ...); + }(nullptr_to>); } } // namespace serialize19 diff --git a/src/serialize19.lib/serialize19/serialize.Tuple.test.cpp b/src/serialize19.lib/serialize19/serialize.Tuple.test.cpp index 50acb65..c62c293 100644 --- a/src/serialize19.lib/serialize19/serialize.Tuple.test.cpp +++ b/src/serialize19.lib/serialize19/serialize.Tuple.test.cpp @@ -21,3 +21,16 @@ TEST(serialize, Tuple) { EXPECT_EQ(output, input); } + +TEST(serialize, Tuple_ints) { + using T = Tuple; + auto input = T{23, 42, 13}; + + auto buffer = dynamicWrite(input); + + auto reader = ReadArchive{buffer.slice()}; + auto output = T{}; + serialize(reader, output); + + EXPECT_EQ(output, input); +} diff --git a/src/serialize19.lib/serialize19/serialize.std_tuple.h b/src/serialize19.lib/serialize19/serialize.std_tuple.h index c6ee837..02f2198 100644 --- a/src/serialize19.lib/serialize19/serialize.std_tuple.h +++ b/src/serialize19.lib/serialize19/serialize.std_tuple.h @@ -1,12 +1,17 @@ #pragma once #include "serialize.h" +#include #include namespace serialize19 { template void serialize(A& a, std::tuple& tuple) { - (serialize(a, std::get(tuple)), ...); + using meta19::nullptr_to; + using meta19::type; + [&](std::index_sequence*) { + (serialize(a, std::get(tuple)), ...); + }(nullptr_to>); } } // namespace serialize19 diff --git a/src/serialize19.lib/serialize19/serialize.std_tuple.test.cpp b/src/serialize19.lib/serialize19/serialize.std_tuple.test.cpp index f6b86e2..8ebd0f8 100644 --- a/src/serialize19.lib/serialize19/serialize.std_tuple.test.cpp +++ b/src/serialize19.lib/serialize19/serialize.std_tuple.test.cpp @@ -19,3 +19,16 @@ TEST(serialize, std_tuple) { EXPECT_EQ(output, input); } + +TEST(serialize, std_tuple_ints) { + using T = std::tuple; + auto input = T{23, 13, 42}; + + auto buffer = dynamicWrite(input); + + auto reader = ReadArchive{buffer.slice()}; + auto output = T{}; + serialize(reader, output); + + EXPECT_EQ(output, input); +}