Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from setuptools import setup, find_packages

name = "cubao_headers"
version = "0.0.7"
version = "0.0.8"

pattern = ["*"]

Expand Down
1 change: 1 addition & 0 deletions include/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- https://github.com/Tessil/ordered-map
- https://github.com/Tessil/robin-map
- https://github.com/cubao/nano-fmm/blob/master/3rdparty/packedrtree.h
- https://github.com/danielaparker/jsoncons/tree/master/include
- https://github.com/district10/geojson-cpp/tree/fef5888142373cc07561987b8c8ba4bd64e2380b
- https://github.com/district10/geometry.hpp/tree/8949904a2b6e0295df2db09b06a643f573e714d0
- https://github.com/doctest/doctest/tree/4d8716f1efc1d14aa736ef52ee727bd4204f4c40
Expand Down
37 changes: 37 additions & 0 deletions include/jsoncons/allocator_holder.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2013-2025 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// See https://github.com/danielaparker/jsoncons for latest version

#ifndef JSONCONS_ALLOCATOR_HOLDER_HPP
#define JSONCONS_ALLOCATOR_HOLDER_HPP

namespace jsoncons {

template <typename Allocator>
class allocator_holder
{
public:
using allocator_type = Allocator;
private:
allocator_type alloc_;
public:
allocator_holder() = default;
allocator_holder(const allocator_holder&) = default;
allocator_holder(allocator_holder&&) = default;
allocator_holder& operator=(const allocator_holder&) = delete;
allocator_holder(const allocator_type& alloc)
: alloc_(alloc)
{}
~allocator_holder() = default;

allocator_type get_allocator() const
{
return alloc_;
}
};

} // namespace jsoncons

#endif // JSONCONS_ALLOCATOR_HOLDER_HPP
67 changes: 67 additions & 0 deletions include/jsoncons/allocator_set.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2013-2025 Daniel Parker
// Distributed under the Boost license, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// See https://github.com/danielaparker/jsoncons for latest version

#ifndef JSONCONS_ALLOCATOR_SET_HPP
#define JSONCONS_ALLOCATOR_SET_HPP

#include <memory>

#include <jsoncons/json_type.hpp>

namespace jsoncons {

template <typename Allocator,typename TempAllocator >
class allocator_set
{
Allocator result_alloc_;
TempAllocator temp_alloc_;
public:
using allocator_type = Allocator;
using temp_allocator_type = TempAllocator;

allocator_set(const Allocator& alloc=Allocator(),
const TempAllocator& temp_alloc=TempAllocator())
: result_alloc_(alloc), temp_alloc_(temp_alloc)
{
}

allocator_set(const allocator_set&) = default;
allocator_set(allocator_set&&) = default;
allocator_set& operator=(const allocator_set&) = delete;
allocator_set& operator=(allocator_set&&) = delete;
~allocator_set() = default;

Allocator get_allocator() const {return result_alloc_;}
TempAllocator get_temp_allocator() const {return temp_alloc_;}
};

inline
allocator_set<std::allocator<char>,std::allocator<char>> combine_allocators()
{
return allocator_set<std::allocator<char>,std::allocator<char>>(std::allocator<char>(), std::allocator<char>());
}

template <typename Allocator>
allocator_set<Allocator,std::allocator<char>> combine_allocators(const Allocator& alloc)
{
return allocator_set<Allocator,std::allocator<char>>(alloc, std::allocator<char>());
}

template <typename Allocator,typename TempAllocator >
allocator_set<Allocator,TempAllocator> combine_allocators(const Allocator& alloc, const TempAllocator& temp_alloc)
{
return allocator_set<Allocator,TempAllocator>(alloc, temp_alloc);
}

template <typename TempAllocator >
allocator_set<std::allocator<char>,TempAllocator> temp_allocator_only(const TempAllocator& temp_alloc)
{
return allocator_set<std::allocator<char>,TempAllocator>(std::allocator<char>(), temp_alloc);
}

} // namespace jsoncons

#endif // JSONCONS_ALLOCATOR_SET_HPP
Loading
Loading