Open stevenwdv opened 3 months ago
@stevenwdv could you please show the least code which can repro this issue? It will help a lot in creating a unit test which covers this issue to avoid it firing in future again
Hi! Apparently the issue occurs when using iterate
with where
+ order_by
, not with only one:
#include <iostream>
#include <string>
#include <sqlite_orm.h> // v1.9
struct Person {
std::string name;
bool dead{};
};
void listPeople(const std::string &path) {
using namespace sqlite_orm;
auto storage = make_storage(path,
make_table("People",
make_column("name", &Person::name)
)
);
for (const auto &person : storage.iterate<Person>(
where(c(&Person::dead) == false),
order_by(&Person::name).asc()
)) {
std::cout << person.name << '\n';
}
}
Working demo on Compiler Explorer%0A++++)%3B%0A++++for+(const+auto+%26person+:+storage.iterate%3CPerson%3E(%0A++++++++where(c(%26Person::dead)+%3D%3D+false),%0A++++++++order_by(%26Person::name).asc()%0A++++))+%7B%0A++++++++std::cout+%3C%3C+person.name+%3C%3C+!'%5Cn!'%3B%0A++++%7D%0A%7D%0A'),l:'5',n:'1',o:'C%2B%2B+source+%231',t:'0')),k:52.158799853640694,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang1810,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!((name:sqlite,ver:'3400')),options:'-std%3Dc%2B%2B20',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+18.1.0+(Editor+%231)',t:'0')),k:47.84120014635933,l:'4',m:46.49963154016212,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+18.1.0+(Compiler+%231)',t:'0')),header:(),l:'4',m:53.50036845983788,n:'0',o:'',s:0,t:'0')),k:47.84120014635933,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
This is a regression since v1.9. When using
iterate
(or more generally,mapped_view
) withwhere()
(or more generally, a condition), I get an error:This is caused by the constructor of
mapped_view
constructingexpression
asexpression{std::forward<Args>(args)...}
, while it should beexpression{{std::forward<Args>(args)...}}
(construct a struct with atuple
inside).I can reproduce this with clang 20.0.0, clang 14.0.0, Apple clang 15.0.0, MSVC 19.39.33523, all with C++20.