Skip to content

Commit 77702f0

Browse files
committed
⬆️ Update to C++23
Problem: - C++23 is supported by our required toolchains, but we are not taking advantage of it. Solution: - Update to C++23. Note: - The `cpp20` branch will be created from `main`. C++20 is still supported on that branch. - Upgrading to C++23 on `main` also means that clang-18 is now the earliest supported clang toolchain.
1 parent dac8b94 commit 77702f0

10 files changed

Lines changed: 79 additions & 209 deletions

File tree

.github/workflows/unit_tests.yml

Lines changed: 4 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
env:
1313
DEBIAN_FRONTEND: noninteractive
1414
CMAKE_GENERATOR: Ninja
15-
DEFAULT_CXX_STANDARD: 20
15+
DEFAULT_CXX_STANDARD: 23
1616
DEFAULT_LLVM_VERSION: 21
1717
DEFAULT_GCC_VERSION: 14
1818
MULL_LLVM_MAJOR_VERSION: 19
@@ -31,8 +31,8 @@ jobs:
3131
fail-fast: false
3232
matrix:
3333
compiler: [clang, gcc]
34-
version: [12, 13, 14, 16, 17, 18, 19, 20, 21]
35-
cxx_standard: [17, 20]
34+
version: [12, 13, 14, 18, 19, 20, 21]
35+
cxx_standard: [23]
3636
stdlib: [libstdc++, libc++]
3737
build_type: [Debug]
3838
include:
@@ -76,24 +76,6 @@ jobs:
7676
stdlib: libc++
7777
install: sudo apt update && sudo apt install -y clang-18 libc++-18-dev libc++abi-18-dev
7878
cxx_flags: "-stdlib=libc++"
79-
- version: 17
80-
compiler: clang
81-
install: sudo apt update && sudo apt install -y clang-17
82-
toolchain_root: "/usr/lib/llvm-17"
83-
- version: 17
84-
compiler: clang
85-
stdlib: libc++
86-
install: sudo apt update && sudo apt install -y clang-17 libc++-17-dev libc++abi-17-dev
87-
cxx_flags: "-stdlib=libc++"
88-
- version: 16
89-
compiler: clang
90-
install: sudo apt update && sudo apt install -y clang-16
91-
toolchain_root: "/usr/lib/llvm-16"
92-
- version: 16
93-
compiler: clang
94-
stdlib: libc++
95-
install: sudo apt update && sudo apt install -y clang-16 libc++-16-dev libc++abi-16-dev
96-
cxx_flags: "-stdlib=libc++"
9779
- compiler: gcc
9880
toolchain_root: "/usr"
9981
cxx_flags: ""
@@ -122,10 +104,6 @@ jobs:
122104
version: 19
123105
- compiler: gcc
124106
version: 18
125-
- compiler: gcc
126-
version: 17
127-
- compiler: gcc
128-
version: 16
129107
- compiler: clang
130108
version: 14
131109
- compiler: clang
@@ -183,92 +161,6 @@ jobs:
183161
working-directory: ${{github.workspace}}/build
184162
run: ctest --output-on-failure -j $(nproc) -C ${{matrix.build_type}}
185163

186-
build_and_test_22:
187-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-22.04
188-
strategy:
189-
fail-fast: false
190-
matrix:
191-
compiler: [clang]
192-
version: [14, 15]
193-
cxx_standard: [17, 20]
194-
stdlib: [libstdc++, libc++]
195-
build_type: [Debug]
196-
include:
197-
- compiler: clang
198-
cc: "clang"
199-
cxx: "clang++"
200-
cxx_flags: "-stdlib=libstdc++"
201-
- version: 15
202-
compiler: clang
203-
install: sudo apt update && sudo apt install -y clang-15
204-
toolchain_root: "/usr/lib/llvm-15"
205-
- version: 15
206-
compiler: clang
207-
stdlib: libc++
208-
install: sudo apt update && sudo apt install -y clang-15 libc++-15-dev libc++abi-15-dev
209-
cxx_flags: "-stdlib=libc++"
210-
- version: 14
211-
compiler: clang
212-
install: sudo apt update && sudo apt install -y clang-14
213-
toolchain_root: "/usr/lib/llvm-14"
214-
- version: 14
215-
compiler: clang
216-
stdlib: libc++
217-
install: sudo apt update && sudo apt install -y clang-14 libc++-14-dev libc++abi-14-dev
218-
cxx_flags: "-stdlib=libc++"
219-
exclude:
220-
- compiler: clang
221-
version: 14
222-
stdlib: libstdc++
223-
224-
steps:
225-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
226-
227-
- name: Install build tools
228-
run: |
229-
${{ matrix.install }}
230-
sudo apt install -y ninja-build python3-venv python3-pip
231-
232-
- name: Restore CPM cache
233-
env:
234-
cache-name: cpm-cache-0
235-
id: cpm-cache-restore
236-
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
237-
with:
238-
path: ~/cpm-cache
239-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
240-
restore-keys: |
241-
${{runner.os}}-${{env.cache-name}}-
242-
243-
- name: Configure CMake
244-
env:
245-
CC: ${{matrix.toolchain_root}}/bin/${{matrix.cc}}
246-
CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}}
247-
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
248-
249-
- name: Save CPM cache
250-
env:
251-
cache-name: cpm-cache-0
252-
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
253-
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
254-
with:
255-
path: ~/cpm-cache
256-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
257-
258-
- name: Install python test requirements
259-
run: |
260-
python3 -m venv ${{github.workspace}}/test_venv
261-
source ${{github.workspace}}/test_venv/bin/activate
262-
pip install -r ${{github.workspace}}/requirements.txt
263-
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
264-
265-
- name: Build Unit Tests
266-
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests
267-
268-
- name: Test
269-
working-directory: ${{github.workspace}}/build
270-
run: ctest --output-on-failure -j $(nproc) -C ${{matrix.build_type}}
271-
272164
quality_checks_pass:
273165
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
274166
steps:
@@ -530,7 +422,7 @@ jobs:
530422

531423
merge_ok:
532424
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
533-
needs: [build_and_test_24, build_and_test_22, mutate, quality_checks_pass, sanitize, valgrind]
425+
needs: [build_and_test_24, mutate, quality_checks_pass, sanitize, valgrind]
534426
if: ${{ !cancelled() }}
535427
steps:
536428
- name: Enable merge

.github/workflows/usage_test.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
usage_test:
19-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-22.04
19+
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
2020
strategy:
2121
fail-fast: false
2222
matrix:
@@ -26,8 +26,8 @@ jobs:
2626
- compiler: clang
2727
cc: "clang"
2828
cxx: "clang++"
29-
install: sudo apt update && sudo apt install -y clang-14
30-
toolchain_root: "/usr/lib/llvm-14"
29+
install: sudo apt update && sudo apt install -y clang-18
30+
toolchain_root: "/usr/lib/llvm-18"
3131
- compiler: gcc
3232
cc: "gcc-12"
3333
cxx: "g++-12"
@@ -44,16 +44,17 @@ jobs:
4444
4545
- name: Install cmake
4646
run: |
47-
pip3 install --upgrade pip
48-
pip3 install --force cmake==${{env.USER_CMAKE_VERSION}}
47+
python3 -m venv ${{github.workspace}}/test_venv
48+
source ${{github.workspace}}/test_venv/bin/activate
49+
pip install cmake==${{env.USER_CMAKE_VERSION}}
4950
50-
- name: Configure CMake
51+
- name: Configure cmake
5152
env:
5253
CC: ${{matrix.toolchain_root}}/bin/${{matrix.cc}}
5354
CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}}
5455
working-directory: ${{github.workspace}}/usage_test
55-
run: ~/.local/bin/cmake -B build -DCPP_IMPLEMENTATION=${{matrix.cpp_implementation}}
56+
run: ${{github.workspace}}/test_venv/bin/cmake -B build -DCPP_IMPLEMENTATION=${{matrix.cpp_implementation}}
5657

5758
- name: Build
5859
working-directory: ${{github.workspace}}/usage_test
59-
run: ~/.local/bin/cmake --build build
60+
run: ${{github.workspace}}/test_venv/bin/cmake --build build

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ else()
1515
endif()
1616

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

2121
if(NOT DEFINED CMAKE_CXX_STANDARD)
22-
set(CMAKE_CXX_STANDARD 20)
22+
set(CMAKE_CXX_STANDARD 23)
2323
endif()
2424

2525
add_library(stdx INTERFACE)

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44

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

7-
- backports to C++17 some standard library features from C++20 and beyond
7+
- backports to C++N some standard library features from C++(>N) and beyond
88
- adds some useful extra utilities that are missing from the standard
9-
10-
Some of the extras are available only with C++20 or later.
11-
12-
*stdx* supports:
13-
14-
- clang 14 through 21
15-
- gcc 12 through 14
169

1710
See the [full documentation](https://intel.github.io/cpp-std-extensions/).
11+
12+
C++ standard support is as follows:
13+
14+
- C++23: [main branch](https://github.com/intel/cpp-std-extensions/tree/main) (active development)
15+
- C++20: [cpp20 branch](https://github.com/intel/cpp-std-extensions/tree/main) (supported)
16+
- 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.
17+
18+
Compiler support:
19+
20+
| Branch | GCC versions | Clang versions |
21+
| --- | --- | --- |
22+
| [main](https://github.com/intel/cpp-baremetal-concurrency/tree/main) | 12 thru 14 | 18 thru 21 |
23+
| [cpp20](https://github.com/intel/cpp-baremetal-concurrency/tree/cpp20) | 12 thru 14 | 14 thru 21 |
24+

include/stdx/functional.hpp

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
#pragma once
22

3+
#include <stdx/tuple.hpp>
34
#include <stdx/type_traits.hpp>
45

56
#include <functional>
67
#include <type_traits>
78

8-
#if __cpp_lib_bind_front < 202306L or __cpp_lib_bind_back < 202306L
9-
#if __cplusplus >= 202002L
10-
#include <stdx/tuple.hpp>
11-
#else
12-
#include <tuple>
13-
#endif
14-
#endif
15-
169
namespace stdx {
1710
inline namespace v1 {
1811

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

3629
namespace detail {
37-
#if __cpp_lib_bind_front < 202306L or __cpp_lib_bind_back < 202306L
38-
#if __cplusplus >= 202002L
3930
template <typename... Ts> using bind_tuple_t = stdx::tuple<Ts...>;
4031
using stdx::get;
41-
#else
42-
template <typename... Ts> using bind_tuple_t = std::tuple<Ts...>;
43-
using std::get;
44-
#endif
45-
#endif
4632
} // namespace detail
4733

48-
#if __cpp_lib_bind_front >= 201907L
49-
using std::bind_front;
50-
#else
5134
namespace detail {
5235
template <typename...> struct bind_front_t;
5336

@@ -77,9 +60,7 @@ constexpr auto bind_front(F &&f, Args &&...args) {
7760
std::decay_t<Args>...>{
7861
std::forward<F>(f), {std::forward<Args>(args)...}};
7962
}
80-
#endif
8163

82-
#if __cpp_lib_bind_front < 202306L
8364
namespace detail {
8465
template <auto, typename...> struct bind_front_value_t;
8566

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

109-
#endif
110-
111-
#if __cpp_lib_bind_back >= 202202L
112-
using std::bind_back;
113-
#else
11490
namespace detail {
11591
template <typename...> struct bind_back_t;
11692

@@ -140,9 +116,7 @@ constexpr auto bind_back(F &&f, Args &&...args) {
140116
std::decay_t<Args>...>{
141117
std::forward<F>(f), {std::forward<Args>(args)...}};
142118
}
143-
#endif
144119

145-
#if __cpp_lib_bind_back < 202306L
146120
namespace detail {
147121
template <auto, typename...> struct bind_back_value_t;
148122

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

172-
#endif
173-
174146
// NOLINTBEGIN(modernize-use-constraints)
175147
template <typename T = void> struct unary_plus {
176148
template <typename U,

include/stdx/utility.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ constexpr static auto reverse_value_lookup_v =
104104
expand<M>())),
105105
detail::value_t<Default>>::value;
106106

107-
#if __cpp_lib_forward_like < 202207L
108107
template <typename T, typename U>
109108
[[nodiscard]] constexpr auto forward_like(U &&u) noexcept -> decltype(auto) {
110109
constexpr auto t_is_const = std::is_const_v<std::remove_reference_t<T>>;
@@ -113,7 +112,7 @@ template <typename T, typename U>
113112
if constexpr (t_is_const) {
114113
return std::as_const(u);
115114
} else {
116-
return (u);
115+
return static_cast<U &>(u);
117116
}
118117
} else {
119118
if constexpr (t_is_const) {
@@ -123,11 +122,9 @@ template <typename T, typename U>
123122
}
124123
}
125124
}
126-
#else
127-
using std::forward_like;
128-
#endif
125+
129126
template <typename T, typename U>
130-
using forward_like_t = decltype(forward_like<T>(std::declval<U>()));
127+
using forward_like_t = decltype(stdx::forward_like<T>(std::declval<U>()));
131128

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

0 commit comments

Comments
 (0)