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
116 changes: 4 additions & 112 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
DEBIAN_FRONTEND: noninteractive
CMAKE_GENERATOR: Ninja
DEFAULT_CXX_STANDARD: 20
DEFAULT_CXX_STANDARD: 23
DEFAULT_LLVM_VERSION: 21
DEFAULT_GCC_VERSION: 14
MULL_LLVM_MAJOR_VERSION: 19
Expand All @@ -31,8 +31,8 @@ jobs:
fail-fast: false
matrix:
compiler: [clang, gcc]
version: [12, 13, 14, 16, 17, 18, 19, 20, 21]
cxx_standard: [17, 20]
version: [12, 13, 14, 18, 19, 20, 21]
cxx_standard: [23]
stdlib: [libstdc++, libc++]
build_type: [Debug]
include:
Expand Down Expand Up @@ -76,24 +76,6 @@ jobs:
stdlib: libc++
install: sudo apt update && sudo apt install -y clang-18 libc++-18-dev libc++abi-18-dev
cxx_flags: "-stdlib=libc++"
- version: 17
compiler: clang
install: sudo apt update && sudo apt install -y clang-17
toolchain_root: "/usr/lib/llvm-17"
- version: 17
compiler: clang
stdlib: libc++
install: sudo apt update && sudo apt install -y clang-17 libc++-17-dev libc++abi-17-dev
cxx_flags: "-stdlib=libc++"
- version: 16
compiler: clang
install: sudo apt update && sudo apt install -y clang-16
toolchain_root: "/usr/lib/llvm-16"
- version: 16
compiler: clang
stdlib: libc++
install: sudo apt update && sudo apt install -y clang-16 libc++-16-dev libc++abi-16-dev
cxx_flags: "-stdlib=libc++"
- compiler: gcc
toolchain_root: "/usr"
cxx_flags: ""
Expand Down Expand Up @@ -122,10 +104,6 @@ jobs:
version: 19
- compiler: gcc
version: 18
- compiler: gcc
version: 17
- compiler: gcc
version: 16
- compiler: clang
version: 14
- compiler: clang
Expand Down Expand Up @@ -183,92 +161,6 @@ jobs:
working-directory: ${{github.workspace}}/build
run: ctest --output-on-failure -j $(nproc) -C ${{matrix.build_type}}

build_and_test_22:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-22.04
strategy:
fail-fast: false
matrix:
compiler: [clang]
version: [14, 15]
cxx_standard: [17, 20]
stdlib: [libstdc++, libc++]
build_type: [Debug]
include:
- compiler: clang
cc: "clang"
cxx: "clang++"
cxx_flags: "-stdlib=libstdc++"
- version: 15
compiler: clang
install: sudo apt update && sudo apt install -y clang-15
toolchain_root: "/usr/lib/llvm-15"
- version: 15
compiler: clang
stdlib: libc++
install: sudo apt update && sudo apt install -y clang-15 libc++-15-dev libc++abi-15-dev
cxx_flags: "-stdlib=libc++"
- version: 14
compiler: clang
install: sudo apt update && sudo apt install -y clang-14
toolchain_root: "/usr/lib/llvm-14"
- version: 14
compiler: clang
stdlib: libc++
install: sudo apt update && sudo apt install -y clang-14 libc++-14-dev libc++abi-14-dev
cxx_flags: "-stdlib=libc++"
exclude:
- compiler: clang
version: 14
stdlib: libstdc++

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install build tools
run: |
${{ matrix.install }}
sudo apt install -y ninja-build python3-venv python3-pip

- name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-

- name: Configure CMake
env:
CC: ${{matrix.toolchain_root}}/bin/${{matrix.cc}}
CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}} -DCMAKE_CXX_FLAGS_INIT=${{matrix.cxx_flags}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCPM_SOURCE_CACHE=~/cpm-cache

- name: Save CPM cache
env:
cache-name: cpm-cache-0
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}

- name: Install python test requirements
run: |
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
pip install -r ${{github.workspace}}/requirements.txt
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH

- name: Build Unit Tests
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest --output-on-failure -j $(nproc) -C ${{matrix.build_type}}

quality_checks_pass:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
steps:
Expand Down Expand Up @@ -530,7 +422,7 @@ jobs:

merge_ok:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
needs: [build_and_test_24, build_and_test_22, mutate, quality_checks_pass, sanitize, valgrind]
needs: [build_and_test_24, mutate, quality_checks_pass, sanitize, valgrind]
if: ${{ !cancelled() }}
steps:
- name: Enable merge
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/usage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:

jobs:
usage_test:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-22.04
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand All @@ -26,8 +26,8 @@ jobs:
- compiler: clang
cc: "clang"
cxx: "clang++"
install: sudo apt update && sudo apt install -y clang-14
toolchain_root: "/usr/lib/llvm-14"
install: sudo apt update && sudo apt install -y clang-18
toolchain_root: "/usr/lib/llvm-18"
- compiler: gcc
cc: "gcc-12"
cxx: "g++-12"
Expand All @@ -44,16 +44,17 @@ jobs:

- name: Install cmake
run: |
pip3 install --upgrade pip
pip3 install --force cmake==${{env.USER_CMAKE_VERSION}}
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
pip install cmake==${{env.USER_CMAKE_VERSION}}

- name: Configure CMake
- name: Configure cmake
env:
CC: ${{matrix.toolchain_root}}/bin/${{matrix.cc}}
CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}}
working-directory: ${{github.workspace}}/usage_test
run: ~/.local/bin/cmake -B build -DCPP_IMPLEMENTATION=${{matrix.cpp_implementation}}
run: ${{github.workspace}}/test_venv/bin/cmake -B build -DCPP_IMPLEMENTATION=${{matrix.cpp_implementation}}

- name: Build
working-directory: ${{github.workspace}}/usage_test
run: ~/.local/bin/cmake --build build
run: ${{github.workspace}}/test_venv/bin/cmake --build build
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ else()
endif()

add_versioned_package("gh:boostorg/mp11#boost-1.83.0")
fmt_recipe(11.1.3)
fmt_recipe(12.1.0)
add_versioned_package("gh:intel/cpp-baremetal-concurrency#06e5901")

if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
endif()

add_library(stdx INTERFACE)
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@

*stdx* is a C++ header-only library that:

- backports to C++17 some standard library features from C++20 and beyond
- backports to C++N some standard library features from C++(>N) and beyond
- adds some useful extra utilities that are missing from the standard

Some of the extras are available only with C++20 or later.

*stdx* supports:

- clang 14 through 21
- gcc 12 through 14

See the [full documentation](https://intel.github.io/cpp-std-extensions/).

C++ standard support is as follows:

- C++23: [main branch](https://github.com/intel/cpp-std-extensions/tree/main) (active development)
- C++20: [cpp20 branch](https://github.com/intel/cpp-std-extensions/tree/main) (supported)
- C++17: unsupported, but many features in the [cpp20 branch](https://github.com/intel/cpp-std-extensions/tree/cpp20) will work with C++17 also.

Compiler support:

| Branch | GCC versions | Clang versions |
| --- | --- | --- |
| [main](https://github.com/intel/cpp-baremetal-concurrency/tree/main) | 12 thru 14 | 18 thru 21 |
| [cpp20](https://github.com/intel/cpp-baremetal-concurrency/tree/cpp20) | 12 thru 14 | 14 thru 21 |

30 changes: 1 addition & 29 deletions include/stdx/functional.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
#pragma once

#include <stdx/tuple.hpp>
#include <stdx/type_traits.hpp>

#include <functional>
#include <type_traits>

#if __cpp_lib_bind_front < 202306L or __cpp_lib_bind_back < 202306L
#if __cplusplus >= 202002L
#include <stdx/tuple.hpp>
#else
#include <tuple>
#endif
#endif

namespace stdx {
inline namespace v1 {

Expand All @@ -34,20 +27,10 @@ template <typename F> with_result_of(F) -> with_result_of<F>;
#endif

namespace detail {
#if __cpp_lib_bind_front < 202306L or __cpp_lib_bind_back < 202306L
#if __cplusplus >= 202002L
template <typename... Ts> using bind_tuple_t = stdx::tuple<Ts...>;
using stdx::get;
#else
template <typename... Ts> using bind_tuple_t = std::tuple<Ts...>;
using std::get;
#endif
#endif
} // namespace detail

#if __cpp_lib_bind_front >= 201907L
using std::bind_front;
#else
namespace detail {
template <typename...> struct bind_front_t;

Expand Down Expand Up @@ -77,9 +60,7 @@ constexpr auto bind_front(F &&f, Args &&...args) {
std::decay_t<Args>...>{
std::forward<F>(f), {std::forward<Args>(args)...}};
}
#endif

#if __cpp_lib_bind_front < 202306L
namespace detail {
template <auto, typename...> struct bind_front_value_t;

Expand All @@ -106,11 +87,6 @@ template <auto F, typename... Args> constexpr auto bind_front(Args &&...args) {
{std::forward<Args>(args)...}};
}

#endif

#if __cpp_lib_bind_back >= 202202L
using std::bind_back;
#else
namespace detail {
template <typename...> struct bind_back_t;

Expand Down Expand Up @@ -140,9 +116,7 @@ constexpr auto bind_back(F &&f, Args &&...args) {
std::decay_t<Args>...>{
std::forward<F>(f), {std::forward<Args>(args)...}};
}
#endif

#if __cpp_lib_bind_back < 202306L
namespace detail {
template <auto, typename...> struct bind_back_value_t;

Expand All @@ -169,8 +143,6 @@ template <auto F, typename... Args> constexpr auto bind_back(Args &&...args) {
{std::forward<Args>(args)...}};
}

#endif

// NOLINTBEGIN(modernize-use-constraints)
template <typename T = void> struct unary_plus {
template <typename U,
Expand Down
9 changes: 3 additions & 6 deletions include/stdx/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ constexpr static auto reverse_value_lookup_v =
expand<M>())),
detail::value_t<Default>>::value;

#if __cpp_lib_forward_like < 202207L
template <typename T, typename U>
[[nodiscard]] constexpr auto forward_like(U &&u) noexcept -> decltype(auto) {
constexpr auto t_is_const = std::is_const_v<std::remove_reference_t<T>>;
Expand All @@ -113,7 +112,7 @@ template <typename T, typename U>
if constexpr (t_is_const) {
return std::as_const(u);
} else {
return (u);
return static_cast<U &>(u); // NOLINT(readability-redundant-casting)
}
} else {
if constexpr (t_is_const) {
Expand All @@ -123,11 +122,9 @@ template <typename T, typename U>
}
}
}
#else
using std::forward_like;
#endif

template <typename T, typename U>
using forward_like_t = decltype(forward_like<T>(std::declval<U>()));
using forward_like_t = decltype(stdx::forward_like<T>(std::declval<U>()));

template <typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>
[[nodiscard]] constexpr auto as_unsigned(T t) {
Expand Down
Loading