Skip to content

Commit

Permalink
build(cmake): bump version
Browse files Browse the repository at this point in the history
Closes #19, #18, #17, #16
  • Loading branch information
c0nstexpr committed Dec 13, 2023
1 parent e624c43 commit e206efd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.24)
#
project(
stdsharp
VERSION 0.8.0
VERSION 0.8.5
LANGUAGES CXX)

include(cmake/Utils.cmake)
Expand Down
9 changes: 5 additions & 4 deletions include/stdsharp/memory/single_stack_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ namespace stdsharp

[[nodiscard]] constexpr T* allocate(const std::size_t s)
{
return pointer_cast<T>(resource().allocate(byte_size(s), alignof(T)));
const auto p = resource().allocate(byte_size(s), alignof(T));
return p == nullptr ? throw std::bad_alloc{} : pointer_cast<T>(p);
}

[[nodiscard]] constexpr T* try_allocate(const std::size_t s)
{
return pointer_cast<T>(resource().try_allocate(byte_size(s), alignof(T)));
return pointer_cast<T>(resource().allocate(byte_size(s), alignof(T)));
}

constexpr void deallocate(T* const ptr, const std::size_t s) noexcept
constexpr void deallocate(T* const ptr, const std::size_t /*unused*/) noexcept
{
resource().deallocate(to_void_pointer(ptr), byte_size(s), alignof(T));
resource().deallocate(to_void_pointer(ptr));
}

[[nodiscard]] constexpr resource_type& resource() const noexcept { return src_.get(); }
Expand Down
21 changes: 3 additions & 18 deletions include/stdsharp/memory/single_stack_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace stdsharp
single_stack_buffer& operator=(single_stack_buffer&&) = delete;
~single_stack_buffer() = default;

[[nodiscard]] constexpr void* try_allocate(
[[nodiscard]] constexpr void* allocate(
const std::size_t s,
const std::size_t alignment = max_alignment_v
) noexcept
Expand All @@ -40,18 +40,7 @@ namespace stdsharp
return p_;
}

[[nodiscard]] constexpr auto
allocate(const std::size_t s, const std::size_t alignment = max_alignment_v)
{
const auto ptr = try_allocate(s, alignment);
return ptr == nullptr ? throw std::bad_alloc{} : ptr;
}

constexpr void deallocate(
void* const p,
const std::size_t /*unused*/,
const std::size_t /*unused*/ = max_alignment_v
) noexcept
constexpr void deallocate(void* const p) noexcept
{
Expects(p_ == p);
p_ = nullptr;
Expand All @@ -62,18 +51,14 @@ namespace stdsharp
return in_ptr == p_;
}

[[nodiscard]] constexpr const auto& buffer() const noexcept
{
return buffer_;
}
[[nodiscard]] constexpr const auto& buffer() const noexcept { return buffer_; }

[[nodiscard]] constexpr bool operator==(const single_stack_buffer& other) const noexcept
{
return this == &other;
}

private:

void* p_ = nullptr;
alignas(std::max_align_t) std::array<byte, size> buffer_{};
};
Expand Down

0 comments on commit e206efd

Please sign in to comment.