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
66 changes: 26 additions & 40 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ jobs:
platform: "ubuntu-latest"
- preset: "gcc-release"
platform: "ubuntu-latest"
- preset: "appleclang-debug"
platform: "macos-latest"
- preset: "appleclang-release"
platform: "macos-latest"
- preset: "msvc-debug"
platform: "windows-latest"
- preset: "msvc-release"
platform: "windows-latest"
name: "Preset: ${{ matrix.presets.preset }} on ${{ matrix.presets.platform }}"
runs-on: ${{ matrix.presets.platform }}
steps:
Expand Down Expand Up @@ -56,13 +48,7 @@ jobs:
- description: "Ubuntu LLVM"
os: ubuntu-latest
toolchain: "cmake/llvm-toolchain.cmake"
- description: "Windows MSVC"
os: windows-latest
toolchain: "cmake/msvc-toolchain.cmake"
- description: "Macos Appleclang"
os: macos-latest
toolchain: "cmake/appleclang-toolchain.cmake"
cpp_version: [17, 20, 23, 26]
cpp_version: [20, 23, 26]
cmake_args:
- description: "Default"
- description: "TSan"
Expand All @@ -74,24 +60,18 @@ jobs:
description: "Ubuntu GCC"
os: ubuntu-latest
toolchain: "cmake/gnu-toolchain.cmake"
cpp_version: 17
cpp_version: 20
cmake_args:
description: "Werror"
args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'"
- platform:
description: "Ubuntu GCC"
os: ubuntu-latest
toolchain: "cmake/gnu-toolchain.cmake"
cpp_version: 17
cpp_version: 20
cmake_args:
description: "Dynamic"
args: "-DBUILD_SHARED_LIBS=on"
exclude:
# MSVC does not support thread sanitizer
- platform:
description: "Windows MSVC"
cmake_args:
description: "TSan"

name: "Unit: ${{ matrix.platform.description }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}"
runs-on: ${{ matrix.platform.os }}
Expand All @@ -107,6 +87,15 @@ jobs:
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Setup LLVM
if: matrix.platform.toolchain == 'cmake/llvm-toolchain.cmake'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo bash llvm.sh 19

sudo ln -sf "$(which clang-19)" /usr/bin/clang
sudo ln -sf "$(which clang++-19)" /usr/bin/clang++
- name: Setup Macos
if: startsWith(matrix.platform.os, 'macos')
run: sudo chmod -R 777 /opt/
Expand Down Expand Up @@ -164,7 +153,7 @@ jobs:
ninja --version
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=17 ${{ matrix.args.arg }}
cmake -B build -S . -DCMAKE_CXX_STANDARD=20 -DCMAKE_TOOLCHAIN_FILE="cmake/gnu-toolchain.cmake" ${{ matrix.args.arg }}
env:
CMAKE_GENERATOR: "Ninja Multi-Config"
- name: Build Release
Expand All @@ -190,18 +179,16 @@ jobs:
compilers:
- class: GNU
version: 14
toolchain: "cmake/gnu-toolchain.cmake"
- class: GNU
version: 13
- class: GNU
version: 12
toolchain: "cmake/gnu-toolchain.cmake"
- class: LLVM
version: 20
toolchain: "cmake/llvm-toolchain.cmake"
- class: LLVM
version: 19
- class: LLVM
version: 18
- class: LLVM
version: 17
toolchain: "cmake/llvm-toolchain.cmake"
name: "Compiler: ${{ matrix.compilers.class }} ${{ matrix.compilers.version }}"
steps:
- uses: actions/checkout@v4
Expand All @@ -222,8 +209,10 @@ jobs:
sudo apt-get install -y $CC
sudo apt-get install -y $CXX

$CC --version
$CXX --version
sudo ln -sf "$(which $CC)" /usr/bin/gcc
sudo ln -sf "$(which $CXX)" /usr/bin/g++

/usr/bin/g++ --version
else
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
Expand All @@ -232,18 +221,15 @@ jobs:
CC=clang-${{ matrix.compilers.version }}
CXX=clang++-${{ matrix.compilers.version }}

$CC --version
$CXX --version
fi
sudo ln -sf "$(which $CC)" /usr/bin/clang
sudo ln -sf "$(which $CXX)" /usr/bin/clang++

echo "CC=$CC" >> "$GITHUB_OUTPUT"
echo "CXX=$CXX" >> "$GITHUB_OUTPUT"
/usr/bin/clang++ --version
fi
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=20
cmake -B build -S . -DCMAKE_CXX_STANDARD=20 -DCMAKE_TOOLCHAIN_FILE="${{ matrix.compilers.toolchain }}"
env:
CC: ${{ steps.install-compiler.outputs.CC }}
CXX: ${{ steps.install-compiler.outputs.CXX }}
CMAKE_GENERATOR: "Ninja Multi-Config"
- name: Build Debug
run: |
Expand Down
58 changes: 26 additions & 32 deletions include/beman/scope/scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#ifndef BEMAN_SCOPE_HPP
#define BEMAN_SCOPE_HPP

#include <type_traits>
#include <utility>

#include <experimental/scope>

namespace beman::scope {

// -- 7.6.7 Feature test macro --
Expand All @@ -13,22 +18,39 @@ namespace beman::scope {
// -- 7.5.1 Header <scope> synopsis [scope.syn] --
//
// namespace std {

// template <class EF>
// class scope_exit;
//
template <class EF>
using scope_exit = std::experimental::scope_exit<EF>;

// template <class EF>
// class scope_fail;
//
template <class EF>
using scope_fail = std::experimental::scope_fail<EF>;

// template <class EF>
// class scope_success;
//
template <class EF>
using scope_success = std::experimental::scope_success<EF>;

// template <class R, class D>
// class unique_resource;
//
template <class R, class D>
using unique_resource = std::experimental::unique_resource<R, D>;

// // factory function
// template <class R, class D, class S = decay_t<R>>
// unique_resource<decay_t<R>, decay_t<D>>
// make_unique_resource_checked(R&& r, const S& invalid, D&& d) noexcept(see below);

template <class R, class D, class S = std::decay_t<R>>
unique_resource<std::decay_t<R>, std::decay_t<D>>
make_unique_resource_checked(R&& r, const S& invalid, D&& d) noexcept(noexcept(
std::experimental::make_unique_resource_checked(std::forward(r), std::forward(invalid), std::forward(d)))) {
return std::experimental::make_unique_resource_checked(std::forward(r), std::forward(invalid), std::forward(d));
}

// } // namespace std
//

Expand Down Expand Up @@ -59,7 +81,6 @@ namespace beman::scope {
// template <class EF>
// scope_guard(EF) -> scope_guard<EF>;
//

// -- 7.6.1 Class template unique_resource [scope.unique_resource.class] --
//
// template <class R, class D>
Expand Down Expand Up @@ -93,33 +114,6 @@ namespace beman::scope {
// template <typename R, typename D>
// unique_resource(R, D) -> unique_resource<R, D>;

// TODO: Implement
struct scope_exit {
template <typename F>
scope_exit(F) {}
~scope_exit() {
// TODO: Cleanup
}
};

// TODO: Implement
struct scope_fail {
template <typename F>
scope_fail(F) {}
~scope_fail() {
// TODO: Cleanup
}
};

// TODO: Implement
struct scope_success {
template <typename F>
scope_success(F) {}
~scope_success() {
// TODO: Cleanup
}
};

} // namespace beman::scope

#endif // BEMAN_SCOPE_HPP