-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(buffer): make span_buffer compile with GCC < 13 during constant e…
- Loading branch information
Showing
4 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Created by neubertt on 09.03.2024. | ||
// | ||
#include "emio/emio.hpp" | ||
|
||
consteval auto created_with_span_buffer() { | ||
std::array<char, 5> storage{}; | ||
emio::span_buffer buf{storage}; | ||
return storage; | ||
} | ||
|
||
consteval auto created_with_static_buffer() { | ||
std::array<char, 5> storage{}; | ||
emio::static_buffer<5> buf{}; | ||
std::span<char> 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<char, 5> storage{}; | ||
emio::memory_buffer<0> buf{}; | ||
std::span<char> 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<char, 5> storage{}; | ||
emio::iterator_buffer buf{storage.data()}; | ||
std::span<char> 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(); | ||
} |