From f7ef78f3519c40462629ef963f481af34bd42c26 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 8 Nov 2024 19:03:29 -0500 Subject: [PATCH] ranges now accept container --- CMakeLists.txt | 2 +- cloc.sh | 0 commit.py.save | 0 include/blt/std/ranges.h | 18 ++++++++++++------ py_commit_helper.sh | 0 src/blt/std/assert.cpp | 14 +++++++------- 6 files changed, 20 insertions(+), 14 deletions(-) mode change 100755 => 100644 cloc.sh mode change 100755 => 100644 commit.py.save mode change 100755 => 100644 py_commit_helper.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 13ca24a..b520c69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 2.1.5) +set(BLT_VERSION 2.1.6) set(BLT_TARGET BLT) diff --git a/cloc.sh b/cloc.sh old mode 100755 new mode 100644 diff --git a/commit.py.save b/commit.py.save old mode 100755 new mode 100644 diff --git a/include/blt/std/ranges.h b/include/blt/std/ranges.h index 87c0538..12d4688 100644 --- a/include/blt/std/ranges.h +++ b/include/blt/std/ranges.h @@ -213,15 +213,18 @@ namespace blt {} template>, typename std::enable_if_t< - extent != dynamic_extent && span_detail::is_cont_v && - std::is_convertible_v()))>(*)[], T(*)[]>, bool> = true> + extent != dynamic_extent && span_detail::is_cont_v, bool> = true> explicit constexpr span(R&& range): size_(std::size(range)), data_(std::data(range)) {} template>, typename std::enable_if_t< - extent == dynamic_extent && span_detail::is_cont_v && - std::is_convertible_v()))>(*)[], T(*)[]>, bool> = true> - constexpr span(R&& range): size_(std::size(range)), data_(std::data(range)) // NOLINT + extent == dynamic_extent && span_detail::is_cont_v, bool> = true> + constexpr span(R& range): size_(std::size(range)), data_(range.data()) // NOLINT + {} + + template>, typename std::enable_if_t< + extent == dynamic_extent && span_detail::is_cont_v, bool> = true> + constexpr span(const R& range): size_(std::size(range)), data_(range.data()) // NOLINT {} template span(T (&)[N]) -> span; + template + span(const T (&)[N]) -> span; + template span(std::array&) -> span; @@ -366,7 +372,7 @@ namespace blt template span(Cont&) -> span; - + template span(const Cont&) -> span; } diff --git a/py_commit_helper.sh b/py_commit_helper.sh old mode 100755 new mode 100644 diff --git a/src/blt/std/assert.cpp b/src/blt/std/assert.cpp index 64b5e80..5ed4440 100644 --- a/src/blt/std/assert.cpp +++ b/src/blt/std/assert.cpp @@ -53,7 +53,7 @@ struct abort_exception final : public std::exception #endif -#if IS_GNU_BACKTRACE +#ifdef IS_GNU_BACKTRACE #define BLT_STACK_TRACE(number) void* ptrs[number]; \ int size = backtrace(ptrs, number); \ char** messages = backtrace_symbols(ptrs, size); @@ -68,7 +68,7 @@ struct abort_exception final : public std::exception namespace blt { -#if IS_GNU_BACKTRACE +#ifdef IS_GNU_BACKTRACE static inline std::string _macro_filename(const std::string& path) { @@ -83,7 +83,7 @@ namespace blt void b_throw(const char* what, const char* path, int line) { -#if IS_GNU_BACKTRACE +#ifdef IS_GNU_BACKTRACE BLT_STACK_TRACE(50); BLT_ERROR("An exception '%s' has occurred in file '%s:%d'", what, path, line); @@ -100,7 +100,7 @@ namespace blt void b_assert_failed(const char* expression, const char* msg, const char* path, int line) { -#if IS_GNU_BACKTRACE +#ifdef IS_GNU_BACKTRACE BLT_STACK_TRACE(50); BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line); @@ -126,7 +126,7 @@ namespace blt { if (messages == nullptr) return; -#if IS_GNU_BACKTRACE +#ifdef IS_GNU_BACKTRACE for (int i = 1; i < size; i++) { int tabs = i - 1; @@ -171,13 +171,13 @@ namespace blt void b_abort(const char* what, const char* path, int line) { -#if IS_GNU_BACKTRACE +#ifdef IS_GNU_BACKTRACE BLT_STACK_TRACE(50); #endif BLT_FATAL("----{BLT ABORT}----"); BLT_FATAL("\tWhat: %s", what); BLT_FATAL("\tCalled from %s:%d", path, line); -#if IS_GNU_BACKTRACE +#ifdef IS_GNU_BACKTRACE printStacktrace(messages, size, path, line); BLT_FREE_STACK_TRACE();