Skip to content

Commit 72549e4

Browse files
authored
Merge pull request #1453 from fnc12/relax_result_iter_requirements
Relax requirements for result set iteration
2 parents 1f82fe2 + 6455e7c commit 72549e4

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

appveyor.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ environment:
2727

2828
- job_name: clang, C++23
2929
appveyor_build_worker_image: Ubuntu2204
30-
CC: clang-18
31-
CXX: clang++-18
30+
CC: clang-20
31+
CXX: clang++-20
3232
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_23=ON"
3333
cmake_build_parallel: ""
3434

@@ -108,7 +108,7 @@ for:
108108
install:
109109
- |-
110110
cd C:\Tools\vcpkg
111-
git fetch --tags && git checkout 2025.04.09
111+
git fetch --tags && git checkout 2025.08.27
112112
cd %APPVEYOR_BUILD_FOLDER%
113113
C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics
114114
C:\Tools\vcpkg\vcpkg integrate install
@@ -142,7 +142,7 @@ for:
142142
install:
143143
- |-
144144
pushd $HOME/vcpkg
145-
git fetch --tags && git checkout 2025.04.09
145+
git fetch --tags && git checkout 2025.08.27
146146
popd
147147
$HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics
148148
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
@@ -170,7 +170,7 @@ for:
170170
# using custom vcpkg triplets for building and linking dynamic dependent libraries
171171
install:
172172
- |-
173-
git clone --depth 1 --branch 2025.04.09 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
173+
git clone --depth 1 --branch 2025.08.27 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
174174
$HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics
175175
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
176176
vcpkg install sqlite3[core,dbstat,math,json1,fts5,soundex] catch2 --overlay-triplets=vcpkg/triplets

dev/result_set_iterator.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "column_result_proxy.h"
1313
#include "util.h"
1414

15-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
1615
namespace sqlite_orm::internal {
1716

1817
template<class ColResult, class DBOs>
@@ -71,6 +70,11 @@ namespace sqlite_orm::internal {
7170
friend bool operator==(const result_set_iterator& it, const result_set_sentinel_t&) noexcept {
7271
return sqlite3_data_count(it.stmt.get()) == 0;
7372
}
73+
#ifndef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
74+
friend bool operator!=(const result_set_iterator& it, const result_set_sentinel_t& s) noexcept {
75+
return !(it == s);
76+
}
77+
#endif
7478

7579
private:
7680
void step() {
@@ -87,4 +91,3 @@ namespace sqlite_orm::internal {
8791
statement_finalizer stmt;
8892
};
8993
}
90-
#endif

dev/result_set_view.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#ifndef SQLITE_ORM_IMPORT_STD_MODULE
55
#include <utility> // std::move, std::remove_cvref
66
#include <functional> // std::reference_wrapper
7-
#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_RANGES_SUPPORTED)
7+
#ifdef SQLITE_ORM_CPP20_RANGES_SUPPORTED
88
#include <ranges> // std::ranges::view_interface
99
#endif
1010
#endif
@@ -18,7 +18,6 @@
1818
#include "type_traits.h"
1919
#include "storage_lookup.h"
2020

21-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
2221
namespace sqlite_orm::internal {
2322
/*
2423
* A C++ view over a result set of a select statement, returned by `storage_t::iterate()`.
@@ -47,7 +46,7 @@ namespace sqlite_orm::internal {
4746

4847
auto begin() {
4948
const auto& exprDBOs = db_objects_for_expression(this->db_objects.get(), this->expression);
50-
using ExprDBOs = std::remove_cvref_t<decltype(exprDBOs)>;
49+
using ExprDBOs = polyfill::remove_cvref_t<decltype(exprDBOs)>;
5150
// note: Select can be `select_t` or `with_t`
5251
using select_type = polyfill::detected_or_t<expression_type, expression_type_t, expression_type>;
5352
using column_result_type = column_result_of_t<ExprDBOs, select_type>;
@@ -82,4 +81,3 @@ namespace sqlite_orm::internal {
8281
template<class Select, class DBOs>
8382
inline constexpr bool std::ranges::enable_borrowed_range<sqlite_orm::internal::result_set_view<Select, DBOs>> = true;
8483
#endif
85-
#endif

dev/storage.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ namespace sqlite_orm {
298298
}
299299
#endif
300300

301-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
302301
/*
303302
* Iterate over a result set of a select statement.
304303
*
@@ -331,7 +330,6 @@ namespace sqlite_orm {
331330
return {this->db_objects, std::move(connection), std::move(expression)};
332331
}
333332
#endif
334-
#endif
335333

336334
#ifdef SQLITE_ORM_CPP23_GENERATOR_SUPPORTED
337335
/*

examples/iteration.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ int main(int, char**) {
6666
}
6767
cout << "heroesByAlgorithm.size = " << heroesByAlgorithm.size() << endl;
6868

69-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
7069
cout << "====" << endl;
7170

7271
cout << "Distinct hero names:" << endl;
7372
for (std::string name: storage.iterate(select(distinct(&MarvelHero::name)))) {
7473
cout << name << endl;
7574
}
76-
#endif
7775

7876
return 0;
7977
}

include/sqlite_orm/sqlite_orm.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16414,7 +16414,7 @@ inline constexpr bool std::ranges::enable_borrowed_range<sqlite_orm::internal::m
1641416414
#ifndef SQLITE_ORM_IMPORT_STD_MODULE
1641516415
#include <utility> // std::move, std::remove_cvref
1641616416
#include <functional> // std::reference_wrapper
16417-
#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_RANGES_SUPPORTED)
16417+
#ifdef SQLITE_ORM_CPP20_RANGES_SUPPORTED
1641816418
#include <ranges> // std::ranges::view_interface
1641916419
#endif
1642016420
#endif
@@ -16440,7 +16440,6 @@ inline constexpr bool std::ranges::enable_borrowed_range<sqlite_orm::internal::m
1644016440

1644116441
// #include "util.h"
1644216442

16443-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
1644416443
namespace sqlite_orm::internal {
1644516444

1644616445
template<class ColResult, class DBOs>
@@ -16499,6 +16498,11 @@ namespace sqlite_orm::internal {
1649916498
friend bool operator==(const result_set_iterator& it, const result_set_sentinel_t&) noexcept {
1650016499
return sqlite3_data_count(it.stmt.get()) == 0;
1650116500
}
16501+
#ifndef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
16502+
friend bool operator!=(const result_set_iterator& it, const result_set_sentinel_t& s) noexcept {
16503+
return !(it == s);
16504+
}
16505+
#endif
1650216506

1650316507
private:
1650416508
void step() {
@@ -16515,7 +16519,6 @@ namespace sqlite_orm::internal {
1651516519
statement_finalizer stmt;
1651616520
};
1651716521
}
16518-
#endif
1651916522

1652016523
// #include "ast_iterator.h"
1652116524

@@ -16527,7 +16530,6 @@ namespace sqlite_orm::internal {
1652716530

1652816531
// #include "storage_lookup.h"
1652916532

16530-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
1653116533
namespace sqlite_orm::internal {
1653216534
/*
1653316535
* A C++ view over a result set of a select statement, returned by `storage_t::iterate()`.
@@ -16556,7 +16558,7 @@ namespace sqlite_orm::internal {
1655616558

1655716559
auto begin() {
1655816560
const auto& exprDBOs = db_objects_for_expression(this->db_objects.get(), this->expression);
16559-
using ExprDBOs = std::remove_cvref_t<decltype(exprDBOs)>;
16561+
using ExprDBOs = polyfill::remove_cvref_t<decltype(exprDBOs)>;
1656016562
// note: Select can be `select_t` or `with_t`
1656116563
using select_type = polyfill::detected_or_t<expression_type, expression_type_t, expression_type>;
1656216564
using column_result_type = column_result_of_t<ExprDBOs, select_type>;
@@ -16591,7 +16593,6 @@ namespace sqlite_orm::internal {
1659116593
template<class Select, class DBOs>
1659216594
inline constexpr bool std::ranges::enable_borrowed_range<sqlite_orm::internal::result_set_view<Select, DBOs>> = true;
1659316595
#endif
16594-
#endif
1659516596

1659616597
// #include "ast_iterator.h"
1659716598

@@ -23411,7 +23412,6 @@ namespace sqlite_orm {
2341123412
}
2341223413
#endif
2341323414

23414-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
2341523415
/*
2341623416
* Iterate over a result set of a select statement.
2341723417
*
@@ -23444,7 +23444,6 @@ namespace sqlite_orm {
2344423444
return {this->db_objects, std::move(connection), std::move(expression)};
2344523445
}
2344623446
#endif
23447-
#endif
2344823447

2344923448
#ifdef SQLITE_ORM_CPP23_GENERATOR_SUPPORTED
2345023449
/*

tests/iterate.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ TEST_CASE("Iterate mapped") {
6161
}
6262
}
6363

64-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
6564
TEST_CASE("Iterate select statement") {
6665
struct Test {
6766
int64_t id = 0;
6867
std::vector<char> key;
6968

69+
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
7070
bool operator==(const Test&) const = default;
71+
#else
72+
bool operator==(const Test& right) const {
73+
return this->id == right.id && this->key == right.key;
74+
}
75+
#endif
7176
};
7277
#ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED
7378
constexpr orm_table_reference auto test_table = c<Test>();
@@ -144,4 +149,3 @@ TEST_CASE("Iterate select statement") {
144149
#endif
145150
#endif
146151
}
147-
#endif

tests/static_tests/iterator_t.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
using namespace sqlite_orm;
1010
using internal::mapped_iterator;
1111
using internal::mapped_view;
12-
using internal::structure;
13-
#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED
1412
using internal::result_set_iterator;
1513
using internal::result_set_sentinel_t;
1614
using internal::result_set_view;
17-
#endif
15+
using internal::structure;
1816
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
1917
using internal::table_reference;
2018
#endif
@@ -81,7 +79,7 @@ concept storage_iterate_mapped_ref = requires(S& storage_type) {
8179
};
8280
#endif
8381

84-
#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED)
82+
#ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED
8583
template<class Iter, class Value>
8684
concept can_iterate_result_set = requires(Iter it) {
8785
requires std::input_iterator<Iter>;
@@ -190,7 +188,7 @@ TEST_CASE("can view and iterate mapped") {
190188
#endif
191189
}
192190

193-
#if defined(SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED) && defined(SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED)
191+
#ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED
194192
TEST_CASE("can view and iterate result set") {
195193
struct Object {};
196194
using empty_storage_type = decltype(make_storage(""));

0 commit comments

Comments
 (0)