5 Commits

Author SHA1 Message Date
Mindaugas Vinkelis
c555088aa3 version 5.0.1 release 2019-08-21 14:03:20 +03:00
Mindaugas Vinkelis
c9619e3e3d macOS compilation fix and polymorphic handler deleter fix 2019-08-21 13:58:43 +03:00
Mindaugas Vinkelis
01d56e00b8 Merge pull request #25 from BotellaA/patch-1
Update memory_resource.h to remove compile warnings
2019-08-21 13:55:33 +03:00
Arnaud Botella
04526ff0f4 Update memory_resource.h 2019-08-01 14:59:15 +02:00
Arnaud Botella
b7d159bbfc Update memory_resource.h
To be consistent with line 135.
2019-08-01 14:43:52 +02:00
6 changed files with 18 additions and 11 deletions

View File

@@ -1,3 +1,10 @@
# [5.0.1](https://github.com/fraillt/bitsery/compare/v5.0.0...v5.0.1) (2019-08-21)
### Bug fixes
* fixed polymorphic handler deleter in `PolymorphicContext`, now it is captured by value and doesn't depend on lifetime of `PolymorphicContext` instance.
* fixed compilation errors in `ext/utils/pointer_utils.h` on macOS.
* reduced warnings on Visual Studio (thanks to [BotellaA](https://github.com/BotellaA))
# [5.0.0](https://github.com/fraillt/bitsery/compare/v4.6.1...v5.0.0) (2019-07-09)
This version reduces library complexity by removing redundant features and changing existing ones.

View File

@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(bitsery
LANGUAGES CXX
VERSION 5.0.0)
VERSION 5.0.1)
#======== build options ===================================
option(BITSERY_BUILD_EXAMPLES "Build examples" OFF)

View File

@@ -26,7 +26,7 @@
#define BITSERY_MAJOR_VERSION 5
#define BITSERY_MINOR_VERSION 0
#define BITSERY_PATCH_VERSION 0
#define BITSERY_PATCH_VERSION 1
#define BITSERY_QUOTE_MACRO(name) #name
#define BITSERY_BUILD_VERSION_STR(major,minor, patch) \

View File

@@ -124,7 +124,8 @@ namespace bitsery {
// it just wraps our PolyAllocWithTypeId and pass 0 as typeId
// and defines core functions for c++ Allocator concept,
template<class T>
struct StdPolyAlloc {
class StdPolyAlloc {
public:
using value_type = T;
explicit constexpr StdPolyAlloc(MemResourceBase* memResource)

View File

@@ -153,7 +153,7 @@ namespace bitsery {
public:
explicit PointerLinkingContextSerialization(MemResourceBase* memResource = nullptr)
: _currId{0},
_ptrMap{StdPolyAlloc<std::pair<const void*, PLCInfoSerializer>>{memResource}} {}
_ptrMap{StdPolyAlloc<std::pair<const void* const, PLCInfoSerializer>>{memResource}} {}
PointerLinkingContextSerialization(const PointerLinkingContextSerialization&) = delete;
@@ -190,7 +190,7 @@ namespace bitsery {
size_t _currId;
std::unordered_map<const void*, PLCInfoSerializer,
std::hash<const void*>, std::equal_to<const void*>,
StdPolyAlloc<std::pair<const void*, PLCInfoSerializer>>
StdPolyAlloc<std::pair<const void* const, PLCInfoSerializer>>
> _ptrMap;
};
@@ -198,7 +198,7 @@ namespace bitsery {
public:
explicit PointerLinkingContextDeserialization(MemResourceBase* memResource = nullptr)
: _memResource{memResource},
_idMap{StdPolyAlloc<std::pair<size_t, PLCInfoDeserializer>>{memResource}} {}
_idMap{StdPolyAlloc<std::pair<const size_t, PLCInfoDeserializer>>{memResource}} {}
PointerLinkingContextDeserialization(const PointerLinkingContextDeserialization&) = delete;
@@ -244,7 +244,7 @@ namespace bitsery {
MemResourceBase* _memResource;
std::unordered_map<size_t, PLCInfoDeserializer,
std::hash<size_t>, std::equal_to<size_t>,
StdPolyAlloc<std::pair<size_t, PLCInfoDeserializer>>> _idMap;
StdPolyAlloc<std::pair<const size_t, PLCInfoDeserializer>>> _idMap;
};
}
@@ -257,7 +257,7 @@ namespace bitsery {
:pointer_utils::PointerLinkingContextSerialization(memResource),
pointer_utils::PointerLinkingContextDeserialization(memResource) {};
bool isValid() {
bool isValid() const {
return isPointerSerializationValid() && isPointerDeserializationValid();
}
};

View File

@@ -144,11 +144,10 @@ namespace bitsery {
BaseToDerivedKey key{RTTI::template get<TBase>(), RTTI::template get<TDerived>()};
pointer_utils::StdPolyAlloc<THandler> alloc{_memResource};
auto ptr = alloc.allocate(1);
std::shared_ptr<THandler> handler(new (ptr)THandler{}, [this](THandler* data) {
std::shared_ptr<THandler> handler(new (ptr)THandler{}, [alloc](THandler* data) mutable {
data->~THandler();
pointer_utils::StdPolyAlloc<THandler> alloc{_memResource};
alloc.deallocate(data, 1);
}, pointer_utils::StdPolyAlloc<THandler>(_memResource));
}, alloc);
if (_baseToDerivedMap
.emplace(key, std::move(handler))
.second) {