Commit 7c69ab52 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

Avoid dangling ref if some code takes assings returned && to another &&

parent 24bfc174
......@@ -172,8 +172,8 @@ template<class T_> class Seq; //!< a Sequence data structure defined below
template<class T_> class Val; //!< a choice of sequence(), record(), null(), or any value with at least a textual representation and possibly binary ones
// Custom bind support
template<typename T> using QBindFunction = Cursor (*)(T &,Val<Cursor>&&);
template<class Ts> using QBindSeqFunction = Seq<Cursor>&&(*)(Ts&,Seq<Cursor>&&);
template<typename T> using QBindFunction = Cursor (*)(T &,Val<Cursor>&&);
template<class Ts> using QBindSeqFunction = Seq<Cursor>(*)(Ts&,Seq<Cursor>&&);
template<class T_> class Val
{
......
......@@ -952,7 +952,7 @@ int main(int argc, char *argv[])
return (fclose(samples)==0) &/*anyway*/ (fclose(results)==0);
}
Seq<Cursor>&& flatten(QList<Person>& ps, Seq<Cursor>&& s) {
Seq<Cursor> flatten(QList<Person>& ps, Seq<Cursor>&& s) {
for (auto&& p : ps) { // Iterating on ps only works for Write but flatten cannot be Read/Write anyway
s = s
.record()
......@@ -1004,7 +1004,7 @@ void doGuiExample() {
});
#else
// More expressive design similar to Python list comprehensions that does not work by default for Read/Write
QModelWriter<>(&customModel).sequence().bind(persons, +[](QList<Person>& t, Seq<Cursor>&& s)->Seq<Cursor>&& { // See https://stackoverflow.com/questions/18889028/a-positive-lambda-what-sorcery-is-this
QModelWriter<>(&customModel).sequence().bind(persons, +[](QList<Person>& t, Seq<Cursor>&& s)->Seq<Cursor> { // See https://stackoverflow.com/questions/18889028/a-positive-lambda-what-sorcery-is-this
for (auto&& person : t) { // Read would require looping while !s.item()
s = s // To keep working with the active Cursor
.record()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment