diff --git a/src/checkpoint/container/vector_serialize.h b/src/checkpoint/container/vector_serialize.h index b449950a..8f973c43 100644 --- a/src/checkpoint/container/vector_serialize.h +++ b/src/checkpoint/container/vector_serialize.h @@ -102,6 +102,22 @@ void serialize(Serializer& s, std::vector& vec) { } } +template < + typename SerializerT, + typename T, + typename VectorAllocator, + typename = std::enable_if_t< + std::is_same< // is_footprintable + size_t, + decltype(checkpoint::getMemoryFootprint(std::declval())) + >::value + > +> +void serialize(SerializerT& s, std::vector& vec) { + s.countBytes(vec); + s.addBytes(vec.capacity() * sizeof(T)); +} + } /* end namespace checkpoint */ #endif /*INCLUDED_CHECKPOINT_CONTAINER_VECTOR_SERIALIZE_H*/ diff --git a/tests/unit/test_footprinter.cc b/tests/unit/test_footprinter.cc index 754ea8e6..33cd8d24 100644 --- a/tests/unit/test_footprinter.cc +++ b/tests/unit/test_footprinter.cc @@ -586,4 +586,17 @@ TEST_F(TestFootprinter, test_ompi) { } } +struct TestNoSerialize { + double d; + int i; +}; + +TEST_F(TestFootprinter, test_no_serialize) { + std::vector v(7); + + EXPECT_EQ( + checkpoint::getMemoryFootprint(v), + sizeof(v) + v.capacity() * sizeof(TestNoSerialize) + ); +} }}} // end namespace checkpoint::tests::unit