Skip to content

Commit 514cadc

Browse files
committed
First pass on C++20-ification of the code
1 parent f6d5127 commit 514cadc

27 files changed

+1055
-1563
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515

1616
env:
1717
BUILD_TYPE: Release
18-
NDK_VER: 21.3.6528147
18+
NDK_VER: 27.2.12479018
1919
NDK_ARCH: x86_64
2020
NDK_API: 29
2121

@@ -28,31 +28,16 @@ jobs:
2828
include:
2929
- os: macos-latest
3030
- os: windows-latest
31-
- os: ubuntu-latest
32-
compiler: gcc
33-
version: 11
34-
- os: ubuntu-latest
35-
compiler: gcc
36-
version: 12
37-
- os: ubuntu-latest
38-
compiler: gcc
39-
version: 13
40-
# See https://github.com/actions/runner-images/issues/8659
41-
# - os: ubuntu-latest
42-
# compiler: clang
43-
# version: 13
44-
# - os: ubuntu-latest
45-
# compiler: clang
46-
# version: 14
47-
- os: ubuntu-latest
48-
compiler: clang
49-
version: 15
50-
- os: ubuntu-latest
51-
compiler: clang
52-
version: 16
53-
- os: ubuntu-latest
54-
compiler: clang
55-
version: 17
31+
- {os: ubuntu-latest, compiler: gcc, version: 11 }
32+
- {os: ubuntu-latest, compiler: gcc, version: 12 }
33+
- {os: ubuntu-latest, compiler: gcc, version: 13 }
34+
- {os: ubuntu-24.04, compiler: gcc, version: 14 }
35+
- {os: ubuntu-latest, compiler: clang, version: 13 }
36+
- {os: ubuntu-latest, compiler: clang, version: 14 }
37+
- {os: ubuntu-latest, compiler: clang, version: 15 }
38+
- {os: ubuntu-latest, compiler: clang, version: 16 }
39+
- {os: ubuntu-latest, compiler: clang, version: 17 }
40+
- {os: ubuntu-latest, compiler: clang, version: 18 }
5641

5742
steps:
5843
- name: Checkout
@@ -61,16 +46,18 @@ jobs:
6146
- name: System Setup
6247
shell: bash
6348
run: |
64-
if [[ '${{ matrix.os }}' == 'ubuntu-latest' ]]; then
49+
if [[ '${{ matrix.os }}' == ubuntu-* ]]; then
6550
if [[ '${{ matrix.compiler }}' == 'clang' ]]; then
6651
wget https://apt.llvm.org/llvm.sh
6752
chmod u+x llvm.sh
68-
sudo ./llvm.sh ${{ matrix.version }}
53+
sudo ./llvm.sh ${{ matrix.version }}
54+
sudo apt-get install -y clang-tools-${{ matrix.version }}
6955
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
7056
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
7157
fi
7258
7359
if [[ '${{ matrix.compiler }}' == 'gcc' ]]; then
60+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
7461
sudo apt-get update
7562
sudo apt-get install -y gcc-${{ matrix.version }} g++-${{ matrix.version }}
7663
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
@@ -149,7 +136,7 @@ jobs:
149136
- name: Set Up Emscripten
150137
uses: mymindstorm/setup-emsdk@v14
151138
with:
152-
version: 3.1.26
139+
version: 3.1.70
153140
actions-cache-folder: 'emsdk-cache'
154141

155142
- name: Configure

lib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ set_target_properties(${LIBNAME} PROPERTIES
3232

3333
target_compile_features(${LIBNAME}
3434
PUBLIC
35-
cxx_std_17
35+
cxx_std_20
3636
)
3737

3838
target_compile_options(${LIBNAME}
@@ -105,7 +105,7 @@ set(UTIL_FILES
105105
${SRCDIR}/inc/sys_string/impl/util/util.h
106106
${SRCDIR}/inc/sys_string/impl/util/char_buffer.h
107107
${SRCDIR}/inc/sys_string/impl/util/generic_buffer.h
108-
${SRCDIR}/inc/sys_string/impl/util/cursor.h
108+
${SRCDIR}/inc/sys_string/impl/util/iter_util.h
109109

110110
)
111111
source_group("Utils" FILES ${UTIL_FILES})

lib/inc/sys_string/config.h

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,18 @@
88
#ifndef HEADER_SYS_STRING_CONFIG_H_INCLUDED
99
#define HEADER_SYS_STRING_CONFIG_H_INCLUDED
1010

11-
#define SYS_STRING_USE_SPACESHIP_OPERATOR (__cpp_impl_three_way_comparison >= 201907)
12-
#define SYS_STRING_USE_CHAR8 (__cpp_char8_t >= 201811)
11+
#if __cplusplus < 202002L || (defined(_MSVC_LANG) && _MSVC_LANG < 202002L)
12+
#error This library requires C++20 or above
13+
#endif
14+
15+
#if __cpp_impl_three_way_comparison < 201907
16+
#error This library requires your compiler to support three-way comparison
17+
#endif
18+
19+
#if __cpp_char8_t < 201811
20+
#error This library requires your compiler to support char8_t
21+
#endif
22+
1323

1424

1525
#if (defined(__APPLE__) && defined(__MACH__))
@@ -80,45 +90,14 @@
8090
#include <version>
8191
#endif
8292

83-
#define SYS_STRING_USE_SPAN (__cpp_lib_span >= 202002)
84-
#define SYS_STRING_USE_STD_ENDIAN (__cpp_lib_endian >= 201907)
85-
#define SYS_STRING_USE_RANGES (__cpp_lib_ranges >= 201911)
86-
87-
#if __cpp_lib_constexpr_algorithms >= 201806
88-
#define SYS_STRING_CONSTEXPR_ALGO constexpr
89-
#else
90-
#define SYS_STRING_CONSTEXPR_ALGO
93+
#if __cpp_lib_endian < 201907
94+
#error Your standard library does not support std::endian
9195
#endif
9296

93-
#if SYS_STRING_USE_STD_ENDIAN
94-
95-
#include <bit>
96-
namespace sysstr
97-
{
98-
using endian = std::endian;
99-
}
100-
101-
#else
102-
103-
namespace sysstr
104-
{
105-
enum class endian
106-
{
107-
#ifdef _MSC_VER
108-
little = 0,
109-
big = 1,
110-
native = little
111-
#elif defined(__BYTE_ORDER__)
112-
little = __ORDER_LITTLE_ENDIAN__,
113-
big = __ORDER_BIG_ENDIAN__,
114-
native = __BYTE_ORDER__
115-
#else
116-
#error Please define byte order values for your compiler
117-
#endif
118-
};
119-
}
120-
97+
#if __cpp_lib_ranges < 201911
98+
#error Your standard library does not support ranges
12199
#endif
122100

123101

102+
124103
#endif

0 commit comments

Comments
 (0)