aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/result.hxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/odb/result.hxx b/odb/result.hxx
index 54c369d..0ca7db1 100644
--- a/odb/result.hxx
+++ b/odb/result.hxx
@@ -45,7 +45,7 @@ namespace odb
typedef odb::object_traits<object_type> object_traits;
result_impl (database_type& db)
- : end_ (false), db_ (db), current_ ()
+ : begin_ (true), end_ (false), db_ (db), current_ ()
{
}
@@ -69,6 +69,16 @@ namespace odb
guard_.release ();
}
+ void
+ begin ()
+ {
+ if (begin_)
+ {
+ next ();
+ begin_ = false;
+ }
+ }
+
bool
end () const
{
@@ -99,6 +109,7 @@ namespace odb
guard_.reset (current_);
}
+ bool begin_;
bool end_;
private:
@@ -269,6 +280,9 @@ namespace odb
iterator
begin ()
{
+ if (impl_)
+ impl_->begin ();
+
return iterator (impl_.get ());
}
@@ -294,7 +308,11 @@ namespace odb
bool
empty () const
{
- return impl_ == 0 || impl_->end ();
+ if (impl_ == 0)
+ return true;
+
+ impl_->begin ();
+ return impl_->end ();
}
// Size is only known in cached results.