Skip to content

Commit

Permalink
#344 Replace std::is_same with checkpoint::is_footprinter
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Whitlock committed Jun 12, 2024
1 parent b45fbe7 commit 4cad937
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/checkpoint/container/atomic_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ template <
typename SerializerT,
typename T,
typename = std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value
checkpoint::is_footprinter<SerializerT>::value
>
>
void serialize(SerializerT& s, const std::atomic<T>& atomic) {
Expand Down
5 changes: 2 additions & 3 deletions src/checkpoint/container/function_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
>
>
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/container/kokkos_unordered_map_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ template <
typename Hasher, typename EqualTo
>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter<SerializerT>::value, void
> serialize(
SerializerT& s,
Kokkos::UnorderedMap<Key, Value, Device, Hasher, EqualTo>& map
Expand All @@ -140,7 +140,7 @@ template <
typename Hasher, typename EqualTo
>
typename std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter<SerializerT>::value, void
> serialize(
SerializerT& s,
Kokkos::UnorderedMap<Key, Value, Device, Hasher, EqualTo>& map
Expand Down
6 changes: 3 additions & 3 deletions src/checkpoint/container/list_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace checkpoint {

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
not std::is_same<Serializer, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter<Serializer>::value, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size,
Expand All @@ -76,7 +76,7 @@ deserializeOrderedElems(

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
not std::is_same<Serializer, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter<Serializer>::value, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size,
Expand All @@ -96,7 +96,7 @@ deserializeOrderedElems(

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
std::is_same<Serializer, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter<Serializer>::value, void
>
deserializeOrderedElems(
Serializer&, ContainerT&, typename ContainerT::size_type
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/container/map_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace checkpoint {

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
not std::is_same<Serializer, checkpoint::Footprinter>::value,
not checkpoint::is_footprinter<Serializer>::value,
void
> deserializeEmplaceElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size
Expand All @@ -77,7 +77,7 @@ inline typename std::enable_if_t<

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
std::is_same<Serializer, checkpoint::Footprinter>::value,
checkpoint::is_footprinter<Serializer>::value,
void
> deserializeEmplaceElems(
Serializer&, ContainerT&, typename ContainerT::size_type
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/queue_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ template <
typename SerializerT,
typename Q,
typename = std::enable_if_t<
std::is_same_v<SerializerT, checkpoint::Footprinter>
checkpoint::is_footprinter<SerializerT>::value
>
>
void serializeQueueLikeContainer(SerializerT& s, const Q& q) {
Expand Down
7 changes: 2 additions & 5 deletions src/checkpoint/container/raw_ptr_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ template <
typename SerializerT,
typename T,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
checkpoint::is_footprinter<SerializerT>::value
>
>
void serialize(SerializerT& s, T* ptr) {
Expand Down Expand Up @@ -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<SerializerT, checkpoint::Footprinter >::value > \
typename = std::enable_if_t< checkpoint::is_footprinter<SerializerT>::value > \
> \
void serialize(SerializerT &s, PIMPL_TYPE *t) { \
s.countBytes(t); \
Expand Down
5 changes: 1 addition & 4 deletions src/checkpoint/container/shared_ptr_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ template <
typename SerializerT,
typename T,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
checkpoint::is_footprinter<SerializerT>::value
>
>
void serialize(SerializerT& s, std::shared_ptr<T>& ptr) {
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/thread_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace checkpoint {
template <
typename SerializerT,
typename = std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value
checkpoint::is_footprinter<SerializerT>::value
>
>
void serialize(SerializerT& s, const std::thread& t) {
Expand Down
10 changes: 5 additions & 5 deletions src/checkpoint/container/vector_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace checkpoint {

template <typename SerializerT, typename T, typename VectorAllocator>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, SerialSizeType
not checkpoint::is_footprinter<SerializerT>::value, SerialSizeType
>
serializeVectorMeta(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
SerialSizeType vec_capacity = vec.capacity();
Expand Down Expand Up @@ -108,7 +108,7 @@ void constructVectorData(

template <typename SerializerT, typename T, typename VectorAllocator>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter<SerializerT>::value, void
>
serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
auto const vec_size = serializeVectorMeta(s, vec);
Expand All @@ -122,7 +122,7 @@ serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {

template <typename SerializerT, typename VectorAllocator>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter<SerializerT>::value, void
>
serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) {
auto const vec_size = serializeVectorMeta(s, vec);
Expand All @@ -146,7 +146,7 @@ serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) {

template <typename SerializerT, typename T, typename VectorAllocator>
typename std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter<SerializerT>::value, void
>
serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
s.countBytes(vec);
Expand All @@ -156,7 +156,7 @@ serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {

template <typename SerializerT, typename VectorAllocator>
typename std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter<SerializerT>::value, void
>
serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) {
s.countBytes(vec);
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/dispatch/dispatch_serializer_nonbyte.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct SerializerDispatchNonByte {
template <typename U>
using justFootprint =
typename std::enable_if<
std::is_same<S, checkpoint::Footprinter>::value and
checkpoint::is_footprinter<S>::value and
not SerializableTraits<U, S>::is_traversable and
not std::is_enum<U>::value,
T
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/dispatch/vrt/virtual_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ struct ReconstructAsVirtualIfNeeded<
SerializerT,
typename std::enable_if_t<
dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize and
not std::is_same<SerializerT, checkpoint::Footprinter>::value
not checkpoint::is_footprinter<SerializerT>::value
>
> {
static T* apply(SerializerT&, dispatch::vrt::TypeIdx) {
Expand All @@ -162,7 +162,7 @@ struct ReconstructAsVirtualIfNeeded<
SerializerT,
typename std::enable_if_t<
dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize and
std::is_same<SerializerT, checkpoint::Footprinter>::value
checkpoint::is_footprinter<SerializerT>::value
>
> {
static T* apply(SerializerT&, dispatch::vrt::TypeIdx) { return nullptr; }
Expand Down
11 changes: 11 additions & 0 deletions src/checkpoint/serializers/footprinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ struct Footprinter : BaseSerializer {
SerialSizeType num_bytes_ = 0;
};

namespace {
template <typename>
struct is_footprinter_impl : public std::false_type {};

template <>
struct is_footprinter_impl<Footprinter> : std::true_type {};
}

template<typename U>
using is_footprinter = is_footprinter_impl<std::decay_t<U>>;

} /* end namespace checkpoint */

#endif /*INCLUDED_CHECKPOINT_SERIALIZERS_FOOTPRINTER_H*/
5 changes: 2 additions & 3 deletions tests/unit/test_footprinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
>
>
Expand Down

0 comments on commit 4cad937

Please sign in to comment.