diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-02-28 16:16:05 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-02-28 16:20:18 +0200 |
commit | 35a2460893ddfd006d9d85dcc6ab7a01c1ab9848 (patch) | |
tree | 0fef3a192febb9249c45a2d21bec6f9aef7c286a | |
parent | 43b3c92c5dae2d851f45fbe04f1c9ac6d9a933f4 (diff) |
Handle C++11 movable object pointers such as std::unique_ptr
-rw-r--r-- | odb/object-result.hxx | 32 | ||||
-rw-r--r-- | odb/view-result.hxx | 17 |
2 files changed, 49 insertions, 0 deletions
diff --git a/odb/object-result.hxx b/odb/object-result.hxx index a2cd92d..759c9f5 100644 --- a/odb/object-result.hxx +++ b/odb/object-result.hxx @@ -9,11 +9,13 @@ #include <cstddef> // std::ptrdiff_t, std::size_t #include <iterator> // iterator categories +#include <utility> // std::move #include <odb/forward.hxx> #include <odb/result.hxx> #include <odb/pointer-traits.hxx> +#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/shared-ptr.hxx> namespace odb @@ -132,12 +134,27 @@ namespace odb size () = 0; protected: +#ifdef ODB_CXX11 + void + current (pointer_type& p) + { + current_ = std::move (p); + guard_.reset (current_); + } + + void + current (pointer_type&& p) + { + current (p); + } +#else void current (pointer_type p) { current_ = p; guard_.reset (current_); } +#endif bool begin_; bool end_; @@ -231,12 +248,27 @@ namespace odb size () = 0; protected: +#ifdef ODB_CXX11 + void + current (pointer_type& p) + { + current_ = std::move (p); + guard_.reset (current_); + } + + void + current (pointer_type&& p) + { + current (p); + } +#else void current (pointer_type p) { current_ = p; guard_.reset (current_); } +#endif bool begin_; bool end_; diff --git a/odb/view-result.hxx b/odb/view-result.hxx index e6de6cb..dbe77a8 100644 --- a/odb/view-result.hxx +++ b/odb/view-result.hxx @@ -9,11 +9,13 @@ #include <cstddef> // std::ptrdiff_t, std::size_t #include <iterator> // iterator categories +#include <utility> // std::move #include <odb/forward.hxx> #include <odb/result.hxx> #include <odb/pointer-traits.hxx> +#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/shared-ptr.hxx> namespace odb @@ -96,12 +98,27 @@ namespace odb size () = 0; protected: +#ifdef ODB_CXX11 + void + current (pointer_type& p) + { + current_ = std::move (p); + guard_.reset (current_); + } + + void + current (pointer_type&& p) + { + current (p); + } +#else void current (pointer_type p) { current_ = p; guard_.reset (current_); } +#endif bool begin_; bool end_; |