Skip to content

Commit fbf74f5

Browse files
committed
Use inline constexpr for some arrays
1 parent 82ace05 commit fbf74f5

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

docs/Changelog.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ When compiled with C++17, **cpp-sort** might gain a few additional features depe
3636

3737
There is no specific feature macro available to test this, it starts working when `std::begin` and `std::end` are `constexpr`.
3838

39-
**Size improvements:**
40-
* When used in different translation units, [`smooth_sorter`][smooth-sorter] might produce fewer duplicates and consume less binary size in C++17.
41-
42-
This optimization is available when the feature-testing macro `__cpp_inline_variables` is available.
43-
4439
## C++20 features
4540

4641
When compiled with C++20, **cpp-sort** might gain a few additional features depending on the level of C++20 support provided by the compiler. The availability of those features depends on the presence of corresponding [feature-testing macros][feature-test-macros] when possible, even though some checks are more granular. Don't hesitate to open an issue if your compiler and standard library supports one of those features but it doesn't seem to work in **cpp-sort**.
@@ -78,7 +73,6 @@ When compiled with C++20, **cpp-sort** might gain a few additional features depe
7873
[feature-test-macros]: https://wg21.link/SD6
7974
[pdq-sorter]: Sorters.md#pdq_sorter
8075
[ska-sorter]: Sorters.md#ska_sorter
81-
[smooth-sorter]: Sorters.md#smooth-sorter_sorter
8276
[sorter-facade]: Sorter-facade.md
8377
[std-greater-void]: https://en.cppreference.com/w/cpp/utility/functional/greater_void
8478
[std-identity]: https://en.cppreference.com/w/cpp/utility/functional/identity

include/cpp-sort/detail/config.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@
2727
# define __has_cpp_attribute(x) 0
2828
#endif
2929

30-
////////////////////////////////////////////////////////////
31-
// Check for C++17 features
32-
33-
// Make sure that there is a single variable before C++17,
34-
// default to static in C++14 to avoid ODR issues
35-
36-
#if defined(__cpp_inline_variables)
37-
# define CPPSORT_INLINE_VARIABLE inline
38-
#else
39-
# define CPPSORT_INLINE_VARIABLE static
40-
#endif
41-
4230
////////////////////////////////////////////////////////////
4331
// Check for C++20 features
4432

include/cpp-sort/detail/smoothsort.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2021 Morwenn
2+
* Copyright (c) 2015-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55

@@ -38,12 +38,12 @@ namespace detail
3838
/* A constant containing the number of Leonardo numbers that can fit into
3939
* 64 bits.
4040
*/
41-
CPPSORT_INLINE_VARIABLE constexpr std::size_t kNumLeonardoNumbers = 92;
41+
inline constexpr std::size_t kNumLeonardoNumbers = 92;
4242

4343
/* A list of all the Leonardo numbers below 2^64, precomputed for
4444
* efficiency.
4545
*/
46-
CPPSORT_INLINE_VARIABLE constexpr std::uint_fast64_t kLeonardoNumbers[kNumLeonardoNumbers] = {
46+
inline constexpr std::uint_fast64_t kLeonardoNumbers[kNumLeonardoNumbers] = {
4747
1u, 1u, 3u, 5u, 9u, 15u, 25u, 41u, 67u, 109u, 177u, 287u, 465u, 753u,
4848
1219u, 1973u, 3193u, 5167u, 8361u, 13529u, 21891u, 35421u, 57313u,
4949
92735u, 150049u, 242785u, 392835u, 635621u, 1028457u, 1664079u,

0 commit comments

Comments
 (0)