Skip to content

Commit 3f8739d

Browse files
committed
Implement Phase 2: Migrate to C++20
## Changes ### C++ Standard Update - Updated CXX_STANDARD from 17 to 20 in CMakeLists.txt - Applied to all targets: - PRTree extension module - benchmark_construction - benchmark_query - benchmark_parallel - stress_test_concurrent ### C++20 Compatibility Fixes - Fixed lambda capture deprecation warning - Changed `[=]` to `[this]` for explicit this capture - Location: Leaf::filter() method ## Testing - ✅ Compiles successfully with C++20 - ✅ No warnings or errors - ✅ All targets build successfully ## Benefits of C++20 - Enables use of C++20 features in future phases: - std::span (Phase 8) - Concepts (Phase 8) - Ranges (Phase 8) - Three-way comparison (Phase 8) - Better compiler optimizations - Improved standard library ## Impact - No API changes - No performance impact expected - Builds on modern compilers (GCC 10+, Clang 10+, MSVC 2019+) Related: Phase 1 (thread safety) Prepares for: Phase 8 (C++20 features)
1 parent 3175a09 commit 3f8739d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ target_link_libraries(PRTree PRIVATE
7070
)
7171

7272
set_target_properties(PRTree PROPERTIES
73-
CXX_STANDARD 17
73+
CXX_STANDARD 20
7474
CXX_STANDARD_REQUIRED TRUE
7575
CXX_EXTENSIONS FALSE
7676
POSITION_INDEPENDENT_CODE ON
@@ -97,7 +97,7 @@ if(BUILD_BENCHMARKS)
9797
target_include_directories(benchmark_construction PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
9898
target_link_libraries(benchmark_construction PRIVATE cereal snappy)
9999
set_target_properties(benchmark_construction PROPERTIES
100-
CXX_STANDARD 17
100+
CXX_STANDARD 20
101101
CXX_STANDARD_REQUIRED TRUE
102102
CXX_EXTENSIONS FALSE
103103
)
@@ -107,7 +107,7 @@ if(BUILD_BENCHMARKS)
107107
target_include_directories(benchmark_query PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
108108
target_link_libraries(benchmark_query PRIVATE cereal snappy)
109109
set_target_properties(benchmark_query PROPERTIES
110-
CXX_STANDARD 17
110+
CXX_STANDARD 20
111111
CXX_STANDARD_REQUIRED TRUE
112112
CXX_EXTENSIONS FALSE
113113
)
@@ -117,7 +117,7 @@ if(BUILD_BENCHMARKS)
117117
target_include_directories(benchmark_parallel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
118118
target_link_libraries(benchmark_parallel PRIVATE cereal snappy)
119119
set_target_properties(benchmark_parallel PROPERTIES
120-
CXX_STANDARD 17
120+
CXX_STANDARD 20
121121
CXX_STANDARD_REQUIRED TRUE
122122
CXX_EXTENSIONS FALSE
123123
)
@@ -127,7 +127,7 @@ if(BUILD_BENCHMARKS)
127127
target_include_directories(stress_test_concurrent PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
128128
target_link_libraries(stress_test_concurrent PRIVATE cereal snappy pthread)
129129
set_target_properties(stress_test_concurrent PROPERTIES
130-
CXX_STANDARD 17
130+
CXX_STANDARD 20
131131
CXX_STANDARD_REQUIRED TRUE
132132
CXX_EXTENSIONS FALSE
133133
)

cpp/prtree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ template <class T, int B = 6, int D = 2> class Leaf {
285285
}
286286

287287
bool filter(DataType<T, D> &value) { // false means given value is ignored
288-
auto comp = [=](const auto &a, const auto &b) noexcept {
288+
// Phase 2: C++20 requires explicit 'this' capture
289+
auto comp = [this](const auto &a, const auto &b) noexcept {
289290
return a.second.val_for_comp(axis) < b.second.val_for_comp(axis);
290291
};
291292

0 commit comments

Comments
 (0)