Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: windows

on: push

jobs:
build:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
build-type: [ Release, Debug ]
compiler: [
{ name: msvc, toolset: v143 },
{ name: clang, toolset: ClangCL }
]

defaults:
run:
working-directory: ${{ github.workspace }}/build

name: ${{ matrix.compiler.name }}-${{ matrix.build-type }}


steps:
- name: checkout-repo
uses: actions/checkout@v4

- name: setup-catch
env:
CMAKE_GENERATOR: "Visual Studio 17 2022"
CMAKE_GENERATOR_TOOLSET: ${{ matrix.compiler.toolset }}
CMAKE_GENERATOR_PLATFORM: ${{ matrix.platform }}
run: bash ../tools/install_catch.sh ${{ matrix.build-type }}

- name: setup-build
env:
CMAKE_GENERATOR: "Visual Studio 17 2022"
CMAKE_GENERATOR_TOOLSET: ${{ matrix.compiler.toolset }}
CMAKE_GENERATOR_PLATFORM: ${{ matrix.platform }}
run: cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DSMP_BUILD_BENCHMARKS=OFF

- name: build
run: cmake --build . --parallel --config ${{ matrix.build-type }}

- name: run-tests
run: ctest --output-on-failure --schedule-random
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*.hint

.cache/
out/
22 changes: 22 additions & 0 deletions src/small_unique_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ namespace smp::detail
template<std::integral T>
constexpr T max_pow2_factor(T n) noexcept { return n & (~n + 1); }

template<typename T, typename U, std::size_t N>
constexpr const void fill(T(&arr)[N], U value)
{
for (std::size_t i = 0; i < N; i++)
arr[i] = value;
}

struct ignore_t
{
Expand Down Expand Up @@ -163,6 +169,14 @@ namespace smp::detail
using pointer = std::remove_cv_t<T>*;
using buffer_t = unsigned char[buffer_size_v<T, Size>];

constexpr small_unique_ptr_base() noexcept
{
if (std::is_constant_evaluated())
{
detail::fill(buffer_, 0);
}
}

pointer buffer(std::ptrdiff_t offset = 0) const noexcept
{
assert(offset <= sizeof(buffer_t));
Expand Down Expand Up @@ -234,6 +248,14 @@ namespace smp::detail
using pointer = std::remove_cv_t<T>*;
using buffer_t = unsigned char[buffer_size_v<T, Size>];

constexpr small_unique_ptr_base() noexcept
{
if (std::is_constant_evaluated())
{
detail::fill(buffer_, 0);
}
}

pointer buffer(std::ptrdiff_t offset = 0) const noexcept
{
assert(offset <= sizeof(buffer_t));
Expand Down