diff --git a/.github/workflows/ubuntu22-cxx20.yml b/.github/workflows/ubuntu22-cxx20.yml new file mode 100644 index 0000000..cc2e5b5 --- /dev/null +++ b/.github/workflows/ubuntu22-cxx20.yml @@ -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 diff --git a/.github/workflows/vs17-cxx20.yml b/.github/workflows/vs17-cxx20.yml new file mode 100644 index 0000000..6dad424 --- /dev/null +++ b/.github/workflows/vs17-cxx20.yml @@ -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 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 97c20a7..09cddc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) diff --git a/src/is_utf8.cpp b/src/is_utf8.cpp index 7321ed4..3fc46b3 100644 --- a/src/is_utf8.cpp +++ b/src/is_utf8.cpp @@ -1116,8 +1116,9 @@ template > struct base_u8 { return *this_cast; } - is_utf8_really_inline Mask operator==(const simd8 other) const { - return vceqq_u8(*this, other); + friend is_utf8_really_inline Mask operator==(const simd8 lhs, + const simd8 rhs) { + return vceqq_u8(lhs, rhs); } template @@ -2539,8 +2540,9 @@ struct base8 : base> { is_utf8_really_inline T last() const { return _mm256_extract_epi8(*this, 31); } - is_utf8_really_inline Mask operator==(const simd8 other) const { - return _mm256_cmpeq_epi8(*this, other); + friend is_utf8_really_inline Mask operator==(const simd8 lhs, + const simd8 rhs) { + return _mm256_cmpeq_epi8(lhs, rhs); } static const int SIZE = sizeof(base::value); @@ -2965,8 +2967,9 @@ struct base16 : base> { is_utf8_really_inline base16(const Pointer *ptr) : base16(_mm256_loadu_si256(reinterpret_cast(ptr))) {} - is_utf8_really_inline Mask operator==(const simd16 other) const { - return _mm256_cmpeq_epi16(*this, other); + friend is_utf8_really_inline Mask operator==(const simd16 lhs, + const simd16 rhs) { + return _mm256_cmpeq_epi16(lhs, rhs); } /// the size of vector in bytes @@ -3517,8 +3520,9 @@ struct base8 : base> { is_utf8_really_inline base8() : base>() {} is_utf8_really_inline base8(const __m128i _value) : base>(_value) {} - is_utf8_really_inline Mask operator==(const simd8 other) const { - return _mm_cmpeq_epi8(*this, other); + friend is_utf8_really_inline Mask operator==(const simd8 lhs, + const simd8 rhs) { + return _mm_cmpeq_epi8(lhs, rhs); } static const int SIZE = sizeof(base>::value); @@ -4032,8 +4036,9 @@ struct base16 : base> { is_utf8_really_inline base16(const Pointer *ptr) : base16(_mm_loadu_si128(reinterpret_cast(ptr))) {} - is_utf8_really_inline Mask operator==(const simd16 other) const { - return _mm_cmpeq_epi16(*this, other); + friend is_utf8_really_inline Mask operator==(const simd16 lhs, + const simd16 rhs) { + return _mm_cmpeq_epi16(lhs, rhs); } static const int SIZE = sizeof(base>::value);