-
|
[ My auto getObj(const std::vector<uint> & ids) {
using namespace sqlite_orm;
if(ids.size() == 0)
return storage->iterate<Obj>();
else
return storage->iterate<Obj>(where(in(&Obj::id,ids)));
}Results in this [ Is this a bug? Similar code using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
it is not a bug cause auto wh = where(in(&Obj::id, ids));
wh = where(is_equal(&Obj::id, 5)); // compilation error will happen on this lineYou'll get compilation error cause |
Beta Was this translation helpful? Give feedback.
-
|
Since PR #1452 and available with C++23, you can iterate over result sets in a type-agnostic manner. auto getObj(const std::vector<uint> & ids) {
using namespace sqlite_orm;
if(ids.size() == 0)
return storage->yield<Obj>();
else
return storage->yield<Obj>(where(in(&Obj::id,ids)));
} |
Beta Was this translation helpful? Give feedback.
it is not a bug cause
storage.iteratefunction returnsview_t<...giant type...>where 'giant type' depends on arguments you pass. The first case has no arguments, the second has. You'll meet the same logic if you write a code like this:You'll get compilation error cause
where_twhich is returned bywherefunction has different template arguments -> it means that these two type returned bywhere(in(&Obj::id, ids))andwhere(is_equal(&Obj::id, 5))are different.Why
get_allreturns the same type withwhereand without it? Cause this is a feature documented and guaranteed bys…