From c7d41a07b00cf3473805455648e5bf315a672dcf Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 13 Oct 2021 19:05:17 +0200 Subject: [PATCH] #161 fix nvcc compilation errors --- src/checkpoint/container/list_serialize.h | 16 ++-- src/checkpoint/container/vector_serialize.h | 20 ++--- src/checkpoint/dispatch/reconstructor.h | 45 ++-------- src/checkpoint/traits/reconstructor_traits.h | 87 ++++++++++---------- 4 files changed, 67 insertions(+), 101 deletions(-) diff --git a/src/checkpoint/container/list_serialize.h b/src/checkpoint/container/list_serialize.h index 968c753c..c1bda13d 100644 --- a/src/checkpoint/container/list_serialize.h +++ b/src/checkpoint/container/list_serialize.h @@ -56,10 +56,11 @@ namespace checkpoint { template inline typename std::enable_if_t< - not std::is_same::value, void> + not std::is_same::value, void +> deserializeOrderedElems( Serializer& s, ContainerT& cont, typename ContainerT::size_type size, - typename ReconstructorTraits::template isCopyConstructible* = nullptr + isCopyConstructible* = nullptr ) { using Alloc = dispatch::Allocator; using Reconstructor = @@ -75,10 +76,11 @@ deserializeOrderedElems( template inline typename std::enable_if_t< - not std::is_same::value, void> + not std::is_same::value, void +> deserializeOrderedElems( Serializer& s, ContainerT& cont, typename ContainerT::size_type size, - typename ReconstructorTraits::template isNotCopyConstructible* = nullptr + isNotCopyConstructible* = nullptr ) { using Alloc = dispatch::Allocator; using Reconstructor = @@ -94,9 +96,9 @@ deserializeOrderedElems( template inline typename std::enable_if_t< - std::is_same::value, - void -> deserializeOrderedElems( + std::is_same::value, void +> +deserializeOrderedElems( Serializer& s, ContainerT& cont, typename ContainerT::size_type size ) { } diff --git a/src/checkpoint/container/vector_serialize.h b/src/checkpoint/container/vector_serialize.h index 3c904054..238e793d 100644 --- a/src/checkpoint/container/vector_serialize.h +++ b/src/checkpoint/container/vector_serialize.h @@ -56,8 +56,7 @@ namespace checkpoint { template typename std::enable_if_t< - not std::is_same::value, - SerialSizeType + not std::is_same::value, SerialSizeType > serializeVectorMeta(SerializerT& s, std::vector& vec) { SerialSizeType vec_capacity = vec.capacity(); @@ -72,7 +71,7 @@ serializeVectorMeta(SerializerT& s, std::vector& vec) { template void constructVectorData( SerialSizeType const vec_size, std::vector& vec, - typename ReconstructorTraits::template isDefaultConsType* = nullptr + isDefaultConsType* = nullptr ) { vec.resize(vec_size); } @@ -80,8 +79,7 @@ void constructVectorData( template void constructVectorData( SerialSizeType const vec_size, std::vector& vec, - typename ReconstructorTraits::template isNotDefaultConsType* = nullptr, - typename ReconstructorTraits::template isCopyConstructible* = nullptr + isNotDefaultConsType* = nullptr, isCopyConstructible* = nullptr ) { using Alloc = dispatch::Allocator; using Reconstructor = @@ -95,8 +93,7 @@ void constructVectorData( template void constructVectorData( SerialSizeType const vec_size, std::vector& vec, - typename ReconstructorTraits::template isNotDefaultConsType* = nullptr, - typename ReconstructorTraits::template isNotCopyConstructible* = nullptr + isNotDefaultConsType* = nullptr, isNotCopyConstructible* = nullptr ) { using Alloc = dispatch::Allocator; using Reconstructor = @@ -111,8 +108,7 @@ void constructVectorData( template typename std::enable_if_t< - not std::is_same::value, - void + not std::is_same::value, void > serialize(SerializerT& s, std::vector& vec) { auto const vec_size = serializeVectorMeta(s, vec); @@ -126,8 +122,7 @@ serialize(SerializerT& s, std::vector& vec) { template typename std::enable_if_t< - not std::is_same::value, - void + not std::is_same::value, void > serialize(SerializerT& s, std::vector& vec) { auto const vec_size = serializeVectorMeta(s, vec); @@ -151,8 +146,7 @@ serialize(SerializerT& s, std::vector& vec) { template typename std::enable_if_t< - std::is_same::value, - void + std::is_same::value, void > serialize(SerializerT& s, std::vector& vec) { s.countBytes(vec); diff --git a/src/checkpoint/dispatch/reconstructor.h b/src/checkpoint/dispatch/reconstructor.h index 6e53a3b2..26b52891 100644 --- a/src/checkpoint/dispatch/reconstructor.h +++ b/src/checkpoint/dispatch/reconstructor.h @@ -57,10 +57,7 @@ template struct Reconstructor { // Default-construct as lowest priority in reconstruction preference template - static T* constructDefault( - void* buf, - typename ReconstructorTraits::template isDefaultConsType* = nullptr - ) { + static T* constructDefault(void* buf, isDefaultConsType* = nullptr) { debug_checkpoint( "DeserializerDispatch: default constructor: buf=%p\n", buf ); @@ -70,10 +67,7 @@ struct Reconstructor { // Fail, no valid option to constructing T template - static T* constructDefault( - void* buf, - typename ReconstructorTraits::template isNotDefaultConsType* = nullptr - ) { + static T* constructDefault(void* buf, isNotDefaultConsType* = nullptr) { static_assert( SerializableTraits::is_tagged_constructible or SerializableTraits::is_reconstructible or @@ -96,10 +90,7 @@ struct Reconstructor { // Intrusive reconstruct template - static T* constructReconstruct( - void* buf, - typename ReconstructorTraits::template isReconstructibleType* = nullptr - ) { + static T* constructReconstruct(void* buf, isReconstructibleType* = nullptr) { debug_checkpoint("DeserializerDispatch: T::reconstruct(): buf=%p\n", buf); auto& t = T::reconstruct(buf); return &t; @@ -107,10 +98,7 @@ struct Reconstructor { // Non-intrusive reconstruct template - static T* constructReconstruct( - void* buf, - typename ReconstructorTraits::template isNonIntReconstructibleType* = nullptr - ) { + static T* constructReconstruct(void* buf, isNonIntReconstructibleType* = nullptr) { debug_checkpoint( "DeserializerDispatch: non-int reconstruct(): buf=%p\n", buf ); @@ -122,19 +110,13 @@ struct Reconstructor { /// Non-reconstruct pass-through template - static T* constructReconstruct( - void* buf, - typename ReconstructorTraits::template isNotReconstructibleType* = nullptr - ) { + static T* constructReconstruct(void* buf, isNotReconstructibleType* = nullptr) { return constructDefault(buf); } /// Tagged constructor template - static T* constructTag( - void* buf, - typename ReconstructorTraits::template isTaggedConstructibleType* = nullptr - ) { + static T* constructTag(void* buf, isTaggedConstructibleType* = nullptr) { debug_checkpoint("DeserializerDispatch: tagged constructor: buf=%p\n", buf); T* t_ptr = new (buf) T{SERIALIZE_CONSTRUCT_TAG{}}; return t_ptr; @@ -142,10 +124,7 @@ struct Reconstructor { /// Non-tagged constructor pass-through template - static T* constructTag( - void* buf, - typename ReconstructorTraits::template isNotTaggedConstructibleType* = nullptr - ) { + static T* constructTag(void* buf, isNotTaggedConstructibleType* = nullptr) { return constructReconstruct(buf); } @@ -157,18 +136,12 @@ struct Reconstructor { /// Overloads that allow failure to reconstruct so SFINAE overloads don't /// static assert out template - static T* constructAllowFailImpl( - void* buf, - typename ReconstructorTraits::template isConstructible* = nullptr - ) { + static T* constructAllowFailImpl(void* buf, isConstructible* = nullptr) { return construct(buf); } template - static T* constructAllowFailImpl( - void* buf, - typename ReconstructorTraits::template isNotConstructible* = nullptr - ) { + static T* constructAllowFailImpl(void* buf, isNotConstructible* = nullptr) { std::unique_ptr msg = std::make_unique(32768); sprintf( &msg[0], diff --git a/src/checkpoint/traits/reconstructor_traits.h b/src/checkpoint/traits/reconstructor_traits.h index f3a48fbf..f91c6e30 100644 --- a/src/checkpoint/traits/reconstructor_traits.h +++ b/src/checkpoint/traits/reconstructor_traits.h @@ -52,51 +52,48 @@ namespace checkpoint { template -struct ReconstructorTraits { - template - using isDefaultConsType = - typename std::enable_if::value, T>::type; - - template - using isNotDefaultConsType = typename std::enable_if< - not std::is_default_constructible::value, T>::type; - - template - using isReconstructibleType = typename std::enable_if< - SerializableTraits::is_intrusive_reconstructible, T>::type; - - template - using isNonIntReconstructibleType = typename std::enable_if< - SerializableTraits::is_nonintrusive_reconstructible, T>::type; - - template - using isNotReconstructibleType = typename std::enable_if< - not SerializableTraits::is_reconstructible, T>::type; - - template - using isTaggedConstructibleType = typename std::enable_if< - SerializableTraits::is_tagged_constructible, T>::type; - - template - using isNotTaggedConstructibleType = typename std::enable_if< - not SerializableTraits::is_tagged_constructible, T>::type; - - template - using isConstructible = typename std::enable_if< - SerializableTraits::is_constructible, T>::type; - - template - using isNotConstructible = typename std::enable_if< - not SerializableTraits::is_constructible, T>::type; - - template - using isCopyConstructible = - typename std::enable_if::value, T>::type; - - template - using isNotCopyConstructible = - typename std::enable_if::value, T>::type; -}; +using isDefaultConsType = + std::enable_if_t::value>; + +template +using isNotDefaultConsType = + std::enable_if_t::value>; + +template +using isReconstructibleType = + std::enable_if_t::is_intrusive_reconstructible>; + +template +using isNonIntReconstructibleType = std::enable_if_t< + SerializableTraits::is_nonintrusive_reconstructible>; + +template +using isNotReconstructibleType = + std::enable_if_t::is_reconstructible>; + +template +using isTaggedConstructibleType = + std::enable_if_t::is_tagged_constructible>; + +template +using isNotTaggedConstructibleType = + std::enable_if_t::is_tagged_constructible>; + +template +using isConstructible = + std::enable_if_t::is_constructible>; + +template +using isNotConstructible = + std::enable_if_t::is_constructible>; + +template +using isNotCopyConstructible = + std::enable_if_t::value>; + +template +using isCopyConstructible = + std::enable_if_t::value>; } // namespace checkpoint