1#ifndef NEFORCE_DATABASE_TRANSACTION_GUARD_HPP__
2#define NEFORCE_DATABASE_TRANSACTION_GUARD_HPP__
23NEFORCE_BEGIN_NAMESPACE__
44template <
typename Connect>
47 Connect* conn_ =
nullptr;
48 bool committed_ =
false;
69 if (conn_ !=
nullptr && !committed_) {
90 committed_(other.committed_) {
91 other.conn_ =
nullptr;
92 other.committed_ =
true;
104 if (conn_ !=
nullptr && !committed_) {
113 committed_ = other.committed_;
114 other.conn_ =
nullptr;
115 other.committed_ =
true;
128 if (conn_ !=
nullptr && !committed_) {
138 NEFORCE_NODISCARD
bool committed() const noexcept {
return committed_; }
146template <
typename Connect>
153NEFORCE_END_NAMESPACE__
scope_transaction(scope_transaction &&other) noexcept
移动构造函数
scope_transaction & operator=(scope_transaction &&other) noexcept
移动赋值运算符
~scope_transaction() noexcept
析构函数
bool committed() const noexcept
检查事务是否已提交
scope_transaction(Connect &conn)
构造函数,开始事务
constexpr T * addressof(T &x) noexcept
获取对象的地址
scope_transaction< Connect > make_transaction(Connect &conn)
事务守卫的便捷构造函数