From 4cad9376c77dcf7c107b83a84d7bc1d4a76b6652 Mon Sep 17 00:00:00 2001 From: Matthew Whitlock Date: Thu, 30 May 2024 10:25:49 -0700 Subject: [PATCH] #344 Replace std::is_same with checkpoint::is_footprinter --- src/checkpoint/container/atomic_serialize.h | 2 +- src/checkpoint/container/function_serialize.h | 5 ++--- .../container/kokkos_unordered_map_serialize.h | 4 ++-- src/checkpoint/container/list_serialize.h | 6 +++--- src/checkpoint/container/map_serialize.h | 4 ++-- src/checkpoint/container/queue_serialize.h | 2 +- src/checkpoint/container/raw_ptr_serialize.h | 7 ++----- src/checkpoint/container/shared_ptr_serialize.h | 5 +---- src/checkpoint/container/thread_serialize.h | 2 +- src/checkpoint/container/vector_serialize.h | 10 +++++----- src/checkpoint/dispatch/dispatch_serializer_nonbyte.h | 2 +- src/checkpoint/dispatch/vrt/virtual_serialize.h | 4 ++-- src/checkpoint/serializers/footprinter.h | 11 +++++++++++ tests/unit/test_footprinter.cc | 5 ++--- 14 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/checkpoint/container/atomic_serialize.h b/src/checkpoint/container/atomic_serialize.h index 098ee91b..53fc6236 100644 --- a/src/checkpoint/container/atomic_serialize.h +++ b/src/checkpoint/container/atomic_serialize.h @@ -54,7 +54,7 @@ template < typename SerializerT, typename T, typename = std::enable_if_t< - std::is_same::value + checkpoint::is_footprinter::value > > void serialize(SerializerT& s, const std::atomic& atomic) { diff --git a/src/checkpoint/container/function_serialize.h b/src/checkpoint/container/function_serialize.h index 7dd4d77d..63096d01 100644 --- a/src/checkpoint/container/function_serialize.h +++ b/src/checkpoint/container/function_serialize.h @@ -68,9 +68,8 @@ template < typename Res, typename... ArgTypes, typename = std::enable_if_t< - std::is_same< - SerializerT, - checkpoint::Footprinter + checkpoint::is_footprinter< + SerializerT >::value > > diff --git a/src/checkpoint/container/kokkos_unordered_map_serialize.h b/src/checkpoint/container/kokkos_unordered_map_serialize.h index 1b5de430..fca87c81 100644 --- a/src/checkpoint/container/kokkos_unordered_map_serialize.h +++ b/src/checkpoint/container/kokkos_unordered_map_serialize.h @@ -117,7 +117,7 @@ template < typename Hasher, typename EqualTo > typename std::enable_if_t< - not std::is_same::value, void + not checkpoint::is_footprinter::value, void > serialize( SerializerT& s, Kokkos::UnorderedMap& map @@ -140,7 +140,7 @@ template < typename Hasher, typename EqualTo > typename std::enable_if_t< - std::is_same::value, void + checkpoint::is_footprinter::value, void > serialize( SerializerT& s, Kokkos::UnorderedMap& map diff --git a/src/checkpoint/container/list_serialize.h b/src/checkpoint/container/list_serialize.h index d616c11f..0629e282 100644 --- a/src/checkpoint/container/list_serialize.h +++ b/src/checkpoint/container/list_serialize.h @@ -56,7 +56,7 @@ namespace checkpoint { template inline typename std::enable_if_t< - not std::is_same::value, void + not checkpoint::is_footprinter::value, void > deserializeOrderedElems( Serializer& s, ContainerT& cont, typename ContainerT::size_type size, @@ -76,7 +76,7 @@ deserializeOrderedElems( template inline typename std::enable_if_t< - not std::is_same::value, void + not checkpoint::is_footprinter::value, void > deserializeOrderedElems( Serializer& s, ContainerT& cont, typename ContainerT::size_type size, @@ -96,7 +96,7 @@ deserializeOrderedElems( template inline typename std::enable_if_t< - std::is_same::value, void + checkpoint::is_footprinter::value, void > deserializeOrderedElems( Serializer&, ContainerT&, typename ContainerT::size_type diff --git a/src/checkpoint/container/map_serialize.h b/src/checkpoint/container/map_serialize.h index 39313a09..9280b45e 100644 --- a/src/checkpoint/container/map_serialize.h +++ b/src/checkpoint/container/map_serialize.h @@ -58,7 +58,7 @@ namespace checkpoint { template inline typename std::enable_if_t< - not std::is_same::value, + not checkpoint::is_footprinter::value, void > deserializeEmplaceElems( Serializer& s, ContainerT& cont, typename ContainerT::size_type size @@ -77,7 +77,7 @@ inline typename std::enable_if_t< template inline typename std::enable_if_t< - std::is_same::value, + checkpoint::is_footprinter::value, void > deserializeEmplaceElems( Serializer&, ContainerT&, typename ContainerT::size_type diff --git a/src/checkpoint/container/queue_serialize.h b/src/checkpoint/container/queue_serialize.h index e90b79fb..b96432f0 100644 --- a/src/checkpoint/container/queue_serialize.h +++ b/src/checkpoint/container/queue_serialize.h @@ -108,7 +108,7 @@ template < typename SerializerT, typename Q, typename = std::enable_if_t< - std::is_same_v + checkpoint::is_footprinter::value > > void serializeQueueLikeContainer(SerializerT& s, const Q& q) { diff --git a/src/checkpoint/container/raw_ptr_serialize.h b/src/checkpoint/container/raw_ptr_serialize.h index d8887efa..eb57a3d2 100644 --- a/src/checkpoint/container/raw_ptr_serialize.h +++ b/src/checkpoint/container/raw_ptr_serialize.h @@ -61,10 +61,7 @@ template < typename SerializerT, typename T, typename = std::enable_if_t< - std::is_same< - SerializerT, - checkpoint::Footprinter - >::value + checkpoint::is_footprinter::value > > void serialize(SerializerT& s, T* ptr) { @@ -95,7 +92,7 @@ void serializeRawPtr(SerializerT& s, void* ptr) { #define CHECKPOINT_FOOTPRINT_PIMPL_WITH_SIZEOF_PTR(PIMPL_TYPE) \ template < \ typename SerializerT, \ - typename = std::enable_if_t< std::is_same::value > \ + typename = std::enable_if_t< checkpoint::is_footprinter::value > \ > \ void serialize(SerializerT &s, PIMPL_TYPE *t) { \ s.countBytes(t); \ diff --git a/src/checkpoint/container/shared_ptr_serialize.h b/src/checkpoint/container/shared_ptr_serialize.h index afe70de0..8e34b43d 100644 --- a/src/checkpoint/container/shared_ptr_serialize.h +++ b/src/checkpoint/container/shared_ptr_serialize.h @@ -52,10 +52,7 @@ template < typename SerializerT, typename T, typename = std::enable_if_t< - std::is_same< - SerializerT, - checkpoint::Footprinter - >::value + checkpoint::is_footprinter::value > > void serialize(SerializerT& s, std::shared_ptr& ptr) { diff --git a/src/checkpoint/container/thread_serialize.h b/src/checkpoint/container/thread_serialize.h index 19510e86..48110732 100644 --- a/src/checkpoint/container/thread_serialize.h +++ b/src/checkpoint/container/thread_serialize.h @@ -53,7 +53,7 @@ namespace checkpoint { template < typename SerializerT, typename = std::enable_if_t< - std::is_same::value + checkpoint::is_footprinter::value > > void serialize(SerializerT& s, const std::thread& t) { diff --git a/src/checkpoint/container/vector_serialize.h b/src/checkpoint/container/vector_serialize.h index 238e793d..ed8f109b 100644 --- a/src/checkpoint/container/vector_serialize.h +++ b/src/checkpoint/container/vector_serialize.h @@ -56,7 +56,7 @@ namespace checkpoint { template typename std::enable_if_t< - not std::is_same::value, SerialSizeType + not checkpoint::is_footprinter::value, SerialSizeType > serializeVectorMeta(SerializerT& s, std::vector& vec) { SerialSizeType vec_capacity = vec.capacity(); @@ -108,7 +108,7 @@ void constructVectorData( template typename std::enable_if_t< - not std::is_same::value, void + not checkpoint::is_footprinter::value, void > serialize(SerializerT& s, std::vector& vec) { auto const vec_size = serializeVectorMeta(s, vec); @@ -122,7 +122,7 @@ serialize(SerializerT& s, std::vector& vec) { template typename std::enable_if_t< - not std::is_same::value, void + not checkpoint::is_footprinter::value, void > serialize(SerializerT& s, std::vector& vec) { auto const vec_size = serializeVectorMeta(s, vec); @@ -146,7 +146,7 @@ serialize(SerializerT& s, std::vector& vec) { template typename std::enable_if_t< - std::is_same::value, void + checkpoint::is_footprinter::value, void > serialize(SerializerT& s, std::vector& vec) { s.countBytes(vec); @@ -156,7 +156,7 @@ serialize(SerializerT& s, std::vector& vec) { template typename std::enable_if_t< - std::is_same::value, void + checkpoint::is_footprinter::value, void > serialize(SerializerT& s, std::vector& vec) { s.countBytes(vec); diff --git a/src/checkpoint/dispatch/dispatch_serializer_nonbyte.h b/src/checkpoint/dispatch/dispatch_serializer_nonbyte.h index 59cd8510..ed9b1fef 100644 --- a/src/checkpoint/dispatch/dispatch_serializer_nonbyte.h +++ b/src/checkpoint/dispatch/dispatch_serializer_nonbyte.h @@ -112,7 +112,7 @@ struct SerializerDispatchNonByte { template using justFootprint = typename std::enable_if< - std::is_same::value and + checkpoint::is_footprinter::value and not SerializableTraits::is_traversable and not std::is_enum::value, T diff --git a/src/checkpoint/dispatch/vrt/virtual_serialize.h b/src/checkpoint/dispatch/vrt/virtual_serialize.h index 0596b88b..5ede7107 100644 --- a/src/checkpoint/dispatch/vrt/virtual_serialize.h +++ b/src/checkpoint/dispatch/vrt/virtual_serialize.h @@ -146,7 +146,7 @@ struct ReconstructAsVirtualIfNeeded< SerializerT, typename std::enable_if_t< dispatch::vrt::VirtualSerializeTraits::has_not_virtual_serialize and - not std::is_same::value + not checkpoint::is_footprinter::value > > { static T* apply(SerializerT&, dispatch::vrt::TypeIdx) { @@ -162,7 +162,7 @@ struct ReconstructAsVirtualIfNeeded< SerializerT, typename std::enable_if_t< dispatch::vrt::VirtualSerializeTraits::has_not_virtual_serialize and - std::is_same::value + checkpoint::is_footprinter::value > > { static T* apply(SerializerT&, dispatch::vrt::TypeIdx) { return nullptr; } diff --git a/src/checkpoint/serializers/footprinter.h b/src/checkpoint/serializers/footprinter.h index 0e315bd4..7945cca4 100644 --- a/src/checkpoint/serializers/footprinter.h +++ b/src/checkpoint/serializers/footprinter.h @@ -72,6 +72,17 @@ struct Footprinter : BaseSerializer { SerialSizeType num_bytes_ = 0; }; +namespace { + template + struct is_footprinter_impl : public std::false_type {}; + + template <> + struct is_footprinter_impl : std::true_type {}; +} + +template +using is_footprinter = is_footprinter_impl>; + } /* end namespace checkpoint */ #endif /*INCLUDED_CHECKPOINT_SERIALIZERS_FOOTPRINTER_H*/ diff --git a/tests/unit/test_footprinter.cc b/tests/unit/test_footprinter.cc index ec0669df..e730a48a 100644 --- a/tests/unit/test_footprinter.cc +++ b/tests/unit/test_footprinter.cc @@ -105,9 +105,8 @@ struct TestDerived2 : TestBase { template < typename SerializerT, typename = std::enable_if_t< - std::is_same< - SerializerT, - checkpoint::Footprinter + checkpoint::is_footprinter< + SerializerT >::value > >