From b564b3e57bd99b0b6db1b7df11557ca283fc9638 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 11 Mar 2024 11:56:15 -0400 Subject: [PATCH] restrict member access --- CMakeLists.txt | 2 +- include/blt/std/allocator.h | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9de8b41..e2976fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) include(cmake/color.cmake) -set(BLT_VERSION 0.14.12) +set(BLT_VERSION 0.14.13) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/std/allocator.h b/include/blt/std/allocator.h index 3f8dac5..b2cd0ff 100644 --- a/include/blt/std/allocator.h +++ b/include/blt/std/allocator.h @@ -567,12 +567,13 @@ namespace blt class stats_t { + friend bump_allocator; private: blt::size_t allocated_blocks = 0; blt::size_t allocated_bytes = 0; blt::size_t peak_blocks = 0; blt::size_t peak_bytes = 0; - public: + protected: inline void incrementBlocks() { allocated_blocks++; @@ -596,27 +597,30 @@ namespace blt { allocated_bytes -= bytes; } + + public: - inline auto getAllocatedBlocks() + inline auto getAllocatedBlocks() const { return allocated_blocks; } - inline auto getAllocatedBytes() + inline auto getAllocatedBytes() const { return allocated_bytes; } - inline auto getPeakBlocks() + inline auto getPeakBlocks() const { return peak_blocks; } - inline auto getPeakBytes() + inline auto getPeakBytes() const { return peak_bytes; } }; + private: stats_t stats;