From fca851cd9dc778342ea63938d7c4d5c44ccd8725 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Fri, 19 Sep 2025 14:01:07 +0300 Subject: [PATCH 1/3] Made result set iteration available for C++17 mode --- dev/result_set_iterator.h | 7 +++++-- dev/result_set_view.h | 6 ++---- dev/storage.h | 2 -- examples/iteration.cpp | 2 -- include/sqlite_orm/sqlite_orm.h | 15 +++++++-------- tests/iterate.cpp | 8 ++++++-- tests/static_tests/iterator_t.cpp | 8 +++----- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/dev/result_set_iterator.h b/dev/result_set_iterator.h index 567e841c..7b38bdf7 100644 --- a/dev/result_set_iterator.h +++ b/dev/result_set_iterator.h @@ -12,7 +12,6 @@ #include "column_result_proxy.h" #include "util.h" -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED namespace sqlite_orm::internal { template @@ -71,6 +70,11 @@ namespace sqlite_orm::internal { friend bool operator==(const result_set_iterator& it, const result_set_sentinel_t&) noexcept { return sqlite3_data_count(it.stmt.get()) == 0; } +#ifndef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED + friend bool operator!=(const result_set_iterator& it, const result_set_sentinel_t& s) noexcept { + return !(it == s); + } +#endif private: void step() { @@ -87,4 +91,3 @@ namespace sqlite_orm::internal { statement_finalizer stmt; }; } -#endif diff --git a/dev/result_set_view.h b/dev/result_set_view.h index 56753033..2aa6b237 100644 --- a/dev/result_set_view.h +++ b/dev/result_set_view.h @@ -4,7 +4,7 @@ #ifndef SQLITE_ORM_IMPORT_STD_MODULE #include // std::move, std::remove_cvref #include // std::reference_wrapper -#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_RANGES_SUPPORTED) +#ifdef SQLITE_ORM_CPP20_RANGES_SUPPORTED #include // std::ranges::view_interface #endif #endif @@ -18,7 +18,6 @@ #include "type_traits.h" #include "storage_lookup.h" -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED namespace sqlite_orm::internal { /* * A C++ view over a result set of a select statement, returned by `storage_t::iterate()`. @@ -47,7 +46,7 @@ namespace sqlite_orm::internal { auto begin() { const auto& exprDBOs = db_objects_for_expression(this->db_objects.get(), this->expression); - using ExprDBOs = std::remove_cvref_t; + using ExprDBOs = polyfill::remove_cvref_t; // note: Select can be `select_t` or `with_t` using select_type = polyfill::detected_or_t; using column_result_type = column_result_of_t; @@ -82,4 +81,3 @@ namespace sqlite_orm::internal { template inline constexpr bool std::ranges::enable_borrowed_range> = true; #endif -#endif diff --git a/dev/storage.h b/dev/storage.h index 15a46a84..e4f39cca 100644 --- a/dev/storage.h +++ b/dev/storage.h @@ -298,7 +298,6 @@ namespace sqlite_orm { } #endif -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED /* * Iterate over a result set of a select statement. * @@ -331,7 +330,6 @@ namespace sqlite_orm { return {this->db_objects, std::move(connection), std::move(expression)}; } #endif -#endif #ifdef SQLITE_ORM_CPP23_GENERATOR_SUPPORTED /* diff --git a/examples/iteration.cpp b/examples/iteration.cpp index a6f2992f..da71ab8b 100644 --- a/examples/iteration.cpp +++ b/examples/iteration.cpp @@ -66,14 +66,12 @@ int main(int, char**) { } cout << "heroesByAlgorithm.size = " << heroesByAlgorithm.size() << endl; -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED cout << "====" << endl; cout << "Distinct hero names:" << endl; for (std::string name: storage.iterate(select(distinct(&MarvelHero::name)))) { cout << name << endl; } -#endif return 0; } diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index dc2375cb..214b3559 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -16414,7 +16414,7 @@ inline constexpr bool std::ranges::enable_borrowed_range // std::move, std::remove_cvref #include // std::reference_wrapper -#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_RANGES_SUPPORTED) +#ifdef SQLITE_ORM_CPP20_RANGES_SUPPORTED #include // std::ranges::view_interface #endif #endif @@ -16440,7 +16440,6 @@ inline constexpr bool std::ranges::enable_borrowed_range @@ -16499,6 +16498,11 @@ namespace sqlite_orm::internal { friend bool operator==(const result_set_iterator& it, const result_set_sentinel_t&) noexcept { return sqlite3_data_count(it.stmt.get()) == 0; } +#ifndef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED + friend bool operator!=(const result_set_iterator& it, const result_set_sentinel_t& s) noexcept { + return !(it == s); + } +#endif private: void step() { @@ -16515,7 +16519,6 @@ namespace sqlite_orm::internal { statement_finalizer stmt; }; } -#endif // #include "ast_iterator.h" @@ -16527,7 +16530,6 @@ namespace sqlite_orm::internal { // #include "storage_lookup.h" -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED namespace sqlite_orm::internal { /* * A C++ view over a result set of a select statement, returned by `storage_t::iterate()`. @@ -16556,7 +16558,7 @@ namespace sqlite_orm::internal { auto begin() { const auto& exprDBOs = db_objects_for_expression(this->db_objects.get(), this->expression); - using ExprDBOs = std::remove_cvref_t; + using ExprDBOs = polyfill::remove_cvref_t; // note: Select can be `select_t` or `with_t` using select_type = polyfill::detected_or_t; using column_result_type = column_result_of_t; @@ -16591,7 +16593,6 @@ namespace sqlite_orm::internal { template inline constexpr bool std::ranges::enable_borrowed_range> = true; #endif -#endif // #include "ast_iterator.h" @@ -23411,7 +23412,6 @@ namespace sqlite_orm { } #endif -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED /* * Iterate over a result set of a select statement. * @@ -23444,7 +23444,6 @@ namespace sqlite_orm { return {this->db_objects, std::move(connection), std::move(expression)}; } #endif -#endif #ifdef SQLITE_ORM_CPP23_GENERATOR_SUPPORTED /* diff --git a/tests/iterate.cpp b/tests/iterate.cpp index 7c57324e..0b9e7f49 100644 --- a/tests/iterate.cpp +++ b/tests/iterate.cpp @@ -61,13 +61,18 @@ TEST_CASE("Iterate mapped") { } } -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED TEST_CASE("Iterate select statement") { struct Test { int64_t id = 0; std::vector key; +#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED bool operator==(const Test&) const = default; +#else + bool operator==(const Test& right) const { + return this->id == right.id && this->key == right.key; + } +#endif }; #ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED constexpr orm_table_reference auto test_table = c(); @@ -144,4 +149,3 @@ TEST_CASE("Iterate select statement") { #endif #endif } -#endif diff --git a/tests/static_tests/iterator_t.cpp b/tests/static_tests/iterator_t.cpp index 540df77b..66abe8fb 100644 --- a/tests/static_tests/iterator_t.cpp +++ b/tests/static_tests/iterator_t.cpp @@ -9,12 +9,10 @@ using namespace sqlite_orm; using internal::mapped_iterator; using internal::mapped_view; -using internal::structure; -#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED using internal::result_set_iterator; using internal::result_set_sentinel_t; using internal::result_set_view; -#endif +using internal::structure; #ifdef SQLITE_ORM_WITH_CPP20_ALIASES using internal::table_reference; #endif @@ -81,7 +79,7 @@ concept storage_iterate_mapped_ref = requires(S& storage_type) { }; #endif -#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED) +#ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED template concept can_iterate_result_set = requires(Iter it) { requires std::input_iterator; @@ -190,7 +188,7 @@ TEST_CASE("can view and iterate mapped") { #endif } -#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED) +#ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED TEST_CASE("can view and iterate result set") { struct Object {}; using empty_storage_type = decltype(make_storage("")); From 7ce5e70f81d863375daded3ae67248348838cb62 Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Fri, 19 Sep 2025 14:06:20 +0300 Subject: [PATCH 2/3] appeyor: Used more recent clang compiler for C++23 build --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c1adb301..18633526 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,8 +27,8 @@ environment: - job_name: clang, C++23 appveyor_build_worker_image: Ubuntu2204 - CC: clang-18 - CXX: clang++-18 + CC: clang-20 + CXX: clang++-20 SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_23=ON" cmake_build_parallel: "" From 6455e7cc0ee3e3c7903fe4a5a91ef06dfa8e40db Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Fri, 19 Sep 2025 14:07:15 +0300 Subject: [PATCH 3/3] appveyor: Updated vcpkg environment to 2025.08.27 --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 18633526..97bc0d98 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -108,7 +108,7 @@ for: install: - |- cd C:\Tools\vcpkg - git fetch --tags && git checkout 2025.04.09 + git fetch --tags && git checkout 2025.08.27 cd %APPVEYOR_BUILD_FOLDER% C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics C:\Tools\vcpkg\vcpkg integrate install @@ -142,7 +142,7 @@ for: install: - |- pushd $HOME/vcpkg - git fetch --tags && git checkout 2025.04.09 + git fetch --tags && git checkout 2025.08.27 popd $HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets @@ -170,7 +170,7 @@ for: # using custom vcpkg triplets for building and linking dynamic dependent libraries install: - |- - git clone --depth 1 --branch 2025.04.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg + git clone --depth 1 --branch 2025.08.27 https://github.com/microsoft/vcpkg.git $HOME/vcpkg $HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics $HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets vcpkg install sqlite3[core,dbstat,math,json1,fts5,soundex] catch2 --overlay-triplets=vcpkg/triplets