Skip to content

Commit 1edd0e4

Browse files
authored
Merge pull request #232 from Morwenn/1.x.y-develop
Release 1.17.0
2 parents 5f4ec36 + e6dbf71 commit 1edd0e4

62 files changed

Lines changed: 1386 additions & 359 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-macos.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2024 Morwenn
1+
# Copyright (c) 2021-2025 Morwenn
22
# SPDX-License-Identifier: MIT
33

44
name: MacOS Builds
@@ -23,30 +23,29 @@ on:
2323

2424
jobs:
2525
build:
26-
runs-on: macos-12
26+
runs-on: macos-13
2727

2828
strategy:
2929
fail-fast: false
3030
matrix:
31-
cxx:
32-
- g++-11
33-
- clang++
3431
config:
3532
# Release build
36-
- build_type: Release
33+
- cxx: g++-12
34+
build_type: Release
35+
- cxx: clang++
36+
build_type: Release
3737
# Debug builds
38-
- build_type: Debug
39-
sanitize: address
40-
- build_type: Debug
41-
sanitize: undefined
38+
- cxx: clang++
39+
build_type: Debug
40+
sanitize: address,undefined
4241

4342
steps:
4443
- uses: actions/checkout@v4
4544

4645
- name: Configure CMake
4746
working-directory: ${{runner.workspace}}
4847
run: |
49-
export CXX=${{matrix.cxx}}
48+
export CXX=${{matrix.config.cxx}}
5049
cmake -H${{github.event.repository.name}} -Bbuild \
5150
-DCMAKE_CONFIGURATION_TYPES=${{matrix.config.build_type}} \
5251
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} \

.github/workflows/build-mingw.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2024 Morwenn
1+
# Copyright (c) 2021-2025 Morwenn
22
# SPDX-License-Identifier: MIT
33

44
name: MinGW-w64 Builds
@@ -23,7 +23,7 @@ on:
2323

2424
jobs:
2525
build:
26-
runs-on: windows-2019
26+
runs-on: windows-2022
2727

2828
strategy:
2929
fail-fast: false
@@ -38,7 +38,6 @@ jobs:
3838
working-directory: ${{runner.workspace}}
3939
run: |
4040
cmake -H${{github.event.repository.name}} -Bbuild `
41-
-DCMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} `
4241
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} `
4342
-G"MinGW Makefiles" `
4443
-DCPPSORT_BUILD_EXAMPLES=ON

.github/workflows/build-msvc.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2024 Morwenn
1+
# Copyright (c) 2021-2025 Morwenn
22
# SPDX-License-Identifier: MIT
33

44
name: MSVC Builds
@@ -23,14 +23,15 @@ on:
2323

2424
jobs:
2525
build:
26-
runs-on: windows-2019
26+
runs-on: windows-2022
2727

2828
strategy:
2929
fail-fast: false
3030
matrix:
3131
config:
3232
- build_type: Release
3333
- build_type: Debug
34+
exclude: "stable_t<hybrid_adapter>"
3435
- build_type: Debug
3536
build_tools: '-T ClangCL'
3637

@@ -44,7 +45,7 @@ jobs:
4445
cmake -H${{github.event.repository.name}} -Bbuild `
4546
-DCMAKE_CONFIGURATION_TYPES=${{matrix.config.build_type}} `
4647
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} `
47-
-G"Visual Studio 16 2019" -A x64 ${{matrix.config.build_tools}} `
48+
-G"Visual Studio 17 2022" -A x64 ${{matrix.config.build_tools}} `
4849
-DCPPSORT_BUILD_EXAMPLES=ON
4950
5051
- name: Build the test suite
@@ -55,4 +56,7 @@ jobs:
5556
env:
5657
CTEST_OUTPUT_ON_FAILURE: 1
5758
working-directory: ${{runner.workspace}}/build
58-
run: ctest -C ${{matrix.config.build_type}} --no-tests=error
59+
run: |
60+
ctest -C ${{matrix.config.build_type}} `
61+
-E "${{matrix.config.exclude}}" `
62+
--no-tests=error

.github/workflows/build-ubuntu.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2024 Morwenn
1+
# Copyright (c) 2021-2025 Morwenn
22
# SPDX-License-Identifier: MIT
33

44
name: Ubuntu Builds
@@ -23,35 +23,33 @@ on:
2323

2424
jobs:
2525
build:
26-
runs-on: ubuntu-20.04
26+
runs-on: ubuntu-22.04
2727

2828
strategy:
2929
fail-fast: false
3030
matrix:
3131
cxx:
32-
- g++-7
33-
- clang++-6.0
32+
- g++-9
33+
- clang++-11
3434
config:
3535
# Release build
3636
- build_type: Release
3737
# Debug builds
3838
- build_type: Debug
3939
valgrind: ON
4040
- build_type: Debug
41-
sanitize: address
42-
- build_type: Debug
43-
sanitize: undefined
41+
sanitize: address,undefined
4442

4543
steps:
4644
- uses: actions/checkout@v4
4745

4846
- name: Install GCC
49-
if: ${{matrix.cxx == 'g++-7'}}
50-
run: sudo apt-get install -y g++-7
47+
if: ${{matrix.cxx == 'g++-9'}}
48+
run: sudo apt-get install -y g++-9
5149

5250
- name: Install Clang
53-
if: ${{matrix.cxx == 'clang++-6.0'}}
54-
run: sudo apt-get install -y clang-6.0 lld-6.0
51+
if: ${{matrix.cxx == 'clang++-11'}}
52+
run: sudo apt-get install -y clang-11 lld-11
5553

5654
- name: Install Valgrind
5755
if: ${{matrix.config.valgrind == 'ON'}}
@@ -73,12 +71,18 @@ jobs:
7371
- name: Build the test suite
7472
shell: bash
7573
working-directory: ${{runner.workspace}}/build
74+
env: # Note: clang bug with sanitizers, remove after upgrading
75+
ASAN_OPTIONS: "use_sigaltstack=false"
76+
UBSAN_OPTIONS: "use_sigaltstack=false"
7677
run: cmake --build . --config ${{matrix.config.build_type}} -j 2
7778

7879
- name: Run the test suite
7980
if: ${{matrix.config.valgrind != 'ON'}}
8081
env:
8182
CTEST_OUTPUT_ON_FAILURE: 1
83+
# Note: clang bug with sanitizers, remove after upgrading
84+
ASAN_OPTIONS: "use_sigaltstack=false"
85+
UBSAN_OPTIONS: "use_sigaltstack=false"
8286
working-directory: ${{runner.workspace}}/build
8387
run: ctest -C ${{matrix.config.build_type}}
8488

.github/workflows/code-coverage.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2024 Morwenn
1+
# Copyright (c) 2020-2025 Morwenn
22
# SPDX-License-Identifier: MIT
33

44
name: Coverage Upload to Codecov
@@ -35,6 +35,8 @@ jobs:
3535
cmake -H${{github.event.repository.name}} -Bbuild
3636
-DCMAKE_BUILD_TYPE=Debug
3737
-DCPPSORT_ENABLE_COVERAGE=ON
38+
-DGENINFO_EXTRA_FLAGS="--ignore-errors mismatch,mismatch"
39+
-DLCOV_EXTRA_FLAGS="--ignore-errors unused"
3840
-G"Unix Makefiles"
3941
4042
- name: Build with coverage

CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Copyright (c) 2015-2024 Morwenn
1+
# Copyright (c) 2015-2025 Morwenn
22
# SPDX-License-Identifier: MIT
33

44
cmake_minimum_required(VERSION 3.8.0)
55

66
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
77

8-
project(cpp-sort VERSION 1.16.0 LANGUAGES CXX)
8+
project(cpp-sort VERSION 1.17.0 LANGUAGES CXX)
99

1010
include(CMakePackageConfigHelpers)
1111
include(GNUInstallDirs)
@@ -24,7 +24,7 @@ if (CPPSORT_USE_LIBASSERT)
2424
include(DownloadProject)
2525
download_project(PROJ libassert
2626
GIT_REPOSITORY https://github.com/jeremy-rifkin/libassert
27-
GIT_TAG v1.2.2
27+
GIT_TAG 634f50fb4086d377ad9a2f83d693d2e8fe4972a7 # v2.1.4
2828
UPDATE_DISCONNECTED 1
2929
)
3030
add_subdirectory(${libassert_SOURCE_DIR} ${libassert_BINARY_DIR})
@@ -42,8 +42,8 @@ target_compile_features(cpp-sort INTERFACE cxx_std_14)
4242
# MSVC won't work without a stricter standard compliance
4343
if (MSVC)
4444
target_compile_options(cpp-sort INTERFACE
45-
/permissive-
46-
/Zc:preprocessor
45+
$<$<COMPILE_LANGUAGE:CXX>:/permissive->
46+
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler="/permissive-">
4747
)
4848
endif()
4949

@@ -57,8 +57,11 @@ endif()
5757

5858
# Optionally link to libassert
5959
if (CPPSORT_USE_LIBASSERT)
60-
target_link_libraries(cpp-sort INTERFACE assert)
60+
target_link_libraries(cpp-sort INTERFACE libassert::assert)
6161
target_compile_definitions(cpp-sort INTERFACE CPPSORT_USE_LIBASSERT)
62+
if (MSVC)
63+
target_compile_options(cpp-sort INTERFACE /Zc:preprocessor)
64+
endif()
6265
endif()
6366

6467
add_library(cpp-sort::cpp-sort ALIAS cpp-sort)
@@ -93,7 +96,7 @@ configure_package_config_file(
9396
set(CPPSORT_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
9497
unset(CMAKE_SIZEOF_VOID_P)
9598
write_basic_package_version_file(
96-
${CMAKE_BINARY_DIR}/cmake/cpp-sort-config-version.cmake
99+
${CMAKE_CURRENT_BINARY_DIR}/cmake/cpp-sort-config-version.cmake
97100
COMPATIBILITY
98101
SameMajorVersion
99102
)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![cpp-sort logo](docs/images/cpp-sort-logo.svg)
22

3-
[![Latest Release](https://img.shields.io/badge/release-1.16.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.16.0)
4-
[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.16.0-blue.svg)](https://conan.io/center/recipes/cpp-sort?version=1.16.0)
3+
[![Latest Release](https://img.shields.io/badge/release-1.17.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.17.0)
4+
[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.17.0-blue.svg)](https://conan.io/center/recipes/cpp-sort?version=1.17.0)
55
[![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort)
66
[![Pitchfork Layout](https://img.shields.io/badge/standard-PFL-orange.svg)](https://github.com/vector-of-bool/pitchfork)
77

@@ -122,8 +122,8 @@ page][benchmarks].
122122
![MacOS builds status](https://github.com/Morwenn/cpp-sort/workflows/MacOS%20Builds/badge.svg?branch=develop)
123123

124124
**cpp-sort** requires C++14 support, and should work with the following compilers:
125-
* g++7 or more recent.
126-
* clang++6.0 or more recent (with both libstdc++ and libc++).
125+
* g++-9 or more recent.
126+
* clang++-11 or more recent (with both libstdc++ and libc++).
127127
* The versions of MinGW-w64 and AppleClang equivalent to the compilers mentioned above.
128128
* Visual Studio 2019 version 16.8.3 or more recent, only with `/permissive-`. A few features are unavailable.
129129
* clang-cl corresponding the the Visual Studio version above.

benchmarks/benchmarking-tools/distributions.h

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2023 Morwenn
2+
* Copyright (c) 2015-2024 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <algorithm>
@@ -13,7 +13,6 @@
1313
#include <cpp-sort/detail/type_traits.h>
1414
#include <cpp-sort/utility/as_function.h>
1515
#include <cpp-sort/utility/functional.h>
16-
#include <cpp-sort/utility/functional.h>
1716

1817
// Pseudo-random number generator, used by some distributions
1918
thread_local std::mt19937_64 distributions_prng(std::time(nullptr));
@@ -422,6 +421,53 @@ namespace dist
422421
static constexpr const char* name = "inv";
423422
};
424423

424+
struct runs:
425+
base_distribution<runs>
426+
{
427+
double factor;
428+
429+
constexpr explicit runs(double factor) noexcept:
430+
factor(factor)
431+
{}
432+
433+
template<typename OutputIterator, typename Projection=cppsort::utility::identity>
434+
auto operator()(OutputIterator out, long long int size, Projection projection={}) const
435+
-> void
436+
{
437+
auto&& proj = cppsort::utility::as_function(projection);
438+
439+
if (size == 0) return;
440+
if (size == 1) {
441+
*out++ = proj(1);
442+
return;
443+
}
444+
445+
// Runs(X) actually computes the number of step-downs in a collection:
446+
// the number of elements smaller than the previous one
447+
auto step_downs = static_cast<long long int>(factor * (size - 1));
448+
// Average number of elements between two step-downs
449+
auto delta = step_downs == 0 ? 0.0 :
450+
static_cast<double>(size - 1) / static_cast<double>(step_downs);
451+
452+
// Generate increasing values, except when encountering a "step-down"
453+
// boundary, in which case we decrease by one: this way of generating
454+
// runs gives evenly sized runs no matter the factor
455+
long long int value = 0;
456+
long long int next_step = 1;
457+
for (long long int idx = 0; idx < size;) {
458+
if (++idx == static_cast<long long int>(next_step * delta)) {
459+
--value;
460+
++next_step;
461+
} else {
462+
++value;
463+
}
464+
*out++ = proj(value);
465+
}
466+
}
467+
468+
static constexpr const char* name = "runs";
469+
};
470+
425471
////////////////////////////////////////////////////////////
426472
// Miscellaneous related tools
427473

benchmarks/presortedness/check-distribution.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
// Configuration variables
1616

1717
// Distribution
18-
using dist_t = dist::inv;
18+
using dist_t = dist::runs;
1919

2020
// Measure of presortedness
21-
auto mop = cppsort::probe::inv;
21+
auto mop = cppsort::probe::runs;
2222

2323
// Size of the collections to check
2424
constexpr std::size_t size = 1'000'000;

cmake/FindGcov.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ foreach (LANG ${ENABLED_LANGUAGES})
3737

3838
elseif ("${CMAKE_${LANG}_COMPILER_ID}" MATCHES "^(Apple)?Clang$")
3939
# Some distributions like Debian ship llvm-cov with the compiler
40-
# version appended as llvm-cov-x.y. To find this binary we'll build
40+
# version appended as llvm-cov-x.y or just llvm-cov-x. To find this binary we'll build
4141
# the suggested binary name with the compiler version.
42-
string(REGEX MATCH "^[0-9]+.[0-9]+" LLVM_VERSION
42+
string(REGEX MATCH "^[0-9]+\.[0-9]+" LLVM_FULL_VERSION
43+
"${CMAKE_${LANG}_COMPILER_VERSION}")
44+
string(REGEX MATCH "^[0-9]+" LLVM_MAJOR_VERSION
4345
"${CMAKE_${LANG}_COMPILER_VERSION}")
4446

4547
# llvm-cov prior version 3.5 seems to be not working with coverage
4648
# evaluation tools, but these versions are compatible with the gcc
4749
# gcov tool.
48-
if(LLVM_VERSION VERSION_GREATER 3.4)
49-
find_program(LLVM_COV_BIN NAMES "llvm-cov-${LLVM_VERSION}"
50+
if(LLVM_FULL_VERSION VERSION_GREATER 3.4)
51+
find_program(LLVM_COV_BIN NAMES "llvm-cov-${LLVM_FULL_VERSION}" "llvm-cov-${LLVM_MAJOR_VERSION}"
5052
"llvm-cov" HINTS ${COMPILER_PATH})
5153
mark_as_advanced(LLVM_COV_BIN)
5254

0 commit comments

Comments
 (0)