Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with C++20 #17

Merged
merged 1 commit into from
May 10, 2024
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
25 changes: 25 additions & 0 deletions .github/workflows/ubuntu22-cxx20.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Ubuntu 22.04 CI (GCC 11, CXX 20)

on: [push, pull_request]

jobs:
ubuntu-build:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Use cmake
run: |
mkdir builddebug &&
cd builddebug &&
cmake -DCMAKE_BUILD_TYPE=Debug -DIS_UTF8_CXX_STANDARD=20 .. &&
cmake --build . &&
ctest -j --output-on-failure -LE explicitonly &&
cd .. &&
mkdir build &&
cd build &&
cmake -DIS_UTF8_CXX_STANDARD=20 .. &&
cmake --build . &&
ctest -j --output-on-failure -LE explicitonly
37 changes: 37 additions & 0 deletions .github/workflows/vs17-cxx20.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: VS17-CI (CXX 20)

on: [push, pull_request]

jobs:
ci:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
name: windows-vs17
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- {gen: Visual Studio 17 2022, arch: x64, shared: ON}
- {gen: Visual Studio 17 2022, arch: x64, shared: OFF}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Configure
run: >
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}}
-DBUILD_SHARED_LIBS=${{matrix.shared}} -DIS_UTF8_CXX_STANDARD=20
-B build
- name: Build Debug
run: cmake --build build --config Debug --verbose
- name: Build Release
run: cmake --build build --config Release --verbose
- name: Run Release tests
run: |
cd build
ctest -C Release -LE explicitonly --output-on-failure
- name: Run Debug tests
run: |
cd build
ctest -C Debug -LE explicitonly --output-on-failure
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ if (NOT CMAKE_BUILD_TYPE)
endif()
endif()

set(CMAKE_CXX_STANDARD 14)
# We compile tools, tests, etc. with C++ 11. Override yourself if you need on a
# target.
set(IS_UTF8_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for is_utf8")

set(CMAKE_CXX_STANDARD ${IS_UTF8_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MACOSX_RPATH OFF)
Expand All @@ -40,6 +44,8 @@ endif(BUILD_TESTING)


add_subdirectory(benchmarks)

message(STATUS "Compiling using the C++ standard:" ${CMAKE_CXX_STANDARD})
# ---- Install rules ----
add_library(is_utf8::is_utf8 ALIAS is_utf8)

Expand Down
25 changes: 15 additions & 10 deletions src/is_utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,8 +1116,9 @@ template <typename T, typename Mask = simd8<bool>> struct base_u8 {
return *this_cast;
}

is_utf8_really_inline Mask operator==(const simd8<T> other) const {
return vceqq_u8(*this, other);
friend is_utf8_really_inline Mask operator==(const simd8<T> lhs,
const simd8<T> rhs) {
return vceqq_u8(lhs, rhs);
}

template <int N = 1>
Expand Down Expand Up @@ -2539,8 +2540,9 @@ struct base8 : base<simd8<T>> {
is_utf8_really_inline T last() const {
return _mm256_extract_epi8(*this, 31);
}
is_utf8_really_inline Mask operator==(const simd8<T> other) const {
return _mm256_cmpeq_epi8(*this, other);
friend is_utf8_really_inline Mask operator==(const simd8<T> lhs,
const simd8<T> rhs) {
return _mm256_cmpeq_epi8(lhs, rhs);
}

static const int SIZE = sizeof(base<T>::value);
Expand Down Expand Up @@ -2965,8 +2967,9 @@ struct base16 : base<simd16<T>> {
is_utf8_really_inline base16(const Pointer *ptr)
: base16(_mm256_loadu_si256(reinterpret_cast<const __m256i *>(ptr))) {}

is_utf8_really_inline Mask operator==(const simd16<T> other) const {
return _mm256_cmpeq_epi16(*this, other);
friend is_utf8_really_inline Mask operator==(const simd16<T> lhs,
const simd16<T> rhs) {
return _mm256_cmpeq_epi16(lhs, rhs);
}

/// the size of vector in bytes
Expand Down Expand Up @@ -3517,8 +3520,9 @@ struct base8 : base<simd8<T>> {
is_utf8_really_inline base8() : base<simd8<T>>() {}
is_utf8_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}

is_utf8_really_inline Mask operator==(const simd8<T> other) const {
return _mm_cmpeq_epi8(*this, other);
friend is_utf8_really_inline Mask operator==(const simd8<T> lhs,
const simd8<T> rhs) {
return _mm_cmpeq_epi8(lhs, rhs);
}

static const int SIZE = sizeof(base<simd8<T>>::value);
Expand Down Expand Up @@ -4032,8 +4036,9 @@ struct base16 : base<simd16<T>> {
is_utf8_really_inline base16(const Pointer *ptr)
: base16(_mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr))) {}

is_utf8_really_inline Mask operator==(const simd16<T> other) const {
return _mm_cmpeq_epi16(*this, other);
friend is_utf8_really_inline Mask operator==(const simd16<T> lhs,
const simd16<T> rhs) {
return _mm_cmpeq_epi16(lhs, rhs);
}

static const int SIZE = sizeof(base<simd16<T>>::value);
Expand Down