Skip to content

Commit

Permalink
update to jsoncons to bbaf3b73b (0.172.1 + additional commits)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmorgan committed Dec 10, 2023
1 parent 6f51c16 commit e859b25
Show file tree
Hide file tree
Showing 143 changed files with 14,812 additions and 9,387 deletions.
2 changes: 1 addition & 1 deletion inst/include/jsoncons/allocator_holder.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Daniel Parker
// Copyright 2013-2023 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)

Expand Down
66 changes: 66 additions & 0 deletions inst/include/jsoncons/allocator_set.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2013-2023 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_STRATEGY_HPP
#define JSONCONS_ALLOCATOR_STRATEGY_HPP

#include <memory>
#include <jsoncons/tag_type.hpp>

namespace jsoncons {

template <class Allocator,class 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 <class Allocator>
allocator_set<Allocator,std::allocator<char>> combine_allocators(const Allocator& alloc)
{
return allocator_set<Allocator,std::allocator<char>>(alloc, std::allocator<char>());
}

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

template <class 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
Loading

0 comments on commit e859b25

Please sign in to comment.