diff --git a/cmake/dev-mode.cmake b/cmake/dev-mode.cmake index 2fe3d24..c8ca2a1 100644 --- a/cmake/dev-mode.cmake +++ b/cmake/dev-mode.cmake @@ -43,9 +43,10 @@ endif () if (BUILD_TESTING) + add_subdirectory(test/benchmark) + add_subdirectory(test/compile_test) add_subdirectory(test/static_analysis) add_subdirectory(test/unit_test) - add_subdirectory(test/benchmark) endif () if (BUILD_SIZE_COVERAGE) diff --git a/include/emio/buffer.hpp b/include/emio/buffer.hpp index 7a03744..92318ca 100644 --- a/include/emio/buffer.hpp +++ b/include/emio/buffer.hpp @@ -217,7 +217,7 @@ class span_buffer : public buffer { constexpr span_buffer(span_buffer&&) noexcept = delete; constexpr span_buffer& operator=(const span_buffer&) = delete; constexpr span_buffer& operator=(span_buffer&&) noexcept = delete; - constexpr ~span_buffer() override = default; + constexpr ~span_buffer() override; /** * Obtains a view over the underlying string object. @@ -254,6 +254,9 @@ class span_buffer : public buffer { std::span span_; }; +// Out-of-line definition because of a GCC bug (93413). Fixed in GCC 13. +inline constexpr span_buffer::~span_buffer() = default; + /** * This class fulfills the buffer API by providing a fixed-size storage. * @tparam StorageSize The size of the storage. diff --git a/test/compile_test/CMakeLists.txt b/test/compile_test/CMakeLists.txt new file mode 100644 index 0000000..a5d71fe --- /dev/null +++ b/test/compile_test/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.14) + +project(emioTests LANGUAGES CXX) + +include(${CMAKE_SOURCE_DIR}/cmake/project-is-top-level.cmake) +include(${CMAKE_SOURCE_DIR}/cmake/folders.cmake) + +if (PROJECT_IS_TOP_LEVEL) + find_package(emio REQUIRED) + enable_testing() +endif () + +add_executable(emio_compile ../compile_test/compile.cpp) + +target_link_libraries(emio_compile + emio::emio +) + +target_compile_features(emio_compile PRIVATE cxx_std_20) + +add_folders(CompileTest) diff --git a/test/compile_test/compile.cpp b/test/compile_test/compile.cpp new file mode 100644 index 0000000..b9c6a6a --- /dev/null +++ b/test/compile_test/compile.cpp @@ -0,0 +1,43 @@ +// +// Created by neubertt on 09.03.2024. +// +#include "emio/emio.hpp" + +consteval auto created_with_span_buffer() { + std::array storage{}; + emio::span_buffer buf{storage}; + return storage; +} + +consteval auto created_with_static_buffer() { + std::array storage{}; + emio::static_buffer<5> buf{}; + std::span area = buf.get_write_area_of(5).value(); + std::fill(area.begin(), area.end(), 'a'); + std::copy(buf.view().begin(), buf.view().end(), storage.begin()); + return storage; +} + +consteval auto created_with_memory_buffer() { + std::array storage{}; + emio::memory_buffer<0> buf{}; + std::span area = buf.get_write_area_of(5).value(); + std::fill(area.begin(), area.end(), 'a'); + std::copy(buf.view().begin(), buf.view().end(), storage.begin()); + return storage; +} + +consteval auto created_with_iterator_buffer() { + std::array storage{}; + emio::iterator_buffer buf{storage.data()}; + std::span area = buf.get_write_area_of(5).value(); + std::fill(area.begin(), area.end(), 'a'); + return storage; +} + +int main() { + created_with_span_buffer(); + created_with_static_buffer(); + created_with_memory_buffer(); + created_with_iterator_buffer(); +}