Merge "Mark scope guard as constexpr"
diff --git a/include/android-base/scopeguard.h b/include/android-base/scopeguard.h
index 5a224d6..8293b2c 100644
--- a/include/android-base/scopeguard.h
+++ b/include/android-base/scopeguard.h
@@ -26,14 +26,14 @@
template <typename F>
class ScopeGuard {
public:
- ScopeGuard(F&& f) : f_(std::forward<F>(f)), active_(true) {}
+ constexpr ScopeGuard(F&& f) : f_(std::forward<F>(f)), active_(true) {}
- ScopeGuard(ScopeGuard&& that) noexcept : f_(std::move(that.f_)), active_(that.active_) {
+ constexpr ScopeGuard(ScopeGuard&& that) noexcept : f_(std::move(that.f_)), active_(that.active_) {
that.active_ = false;
}
template <typename Functor>
- ScopeGuard(ScopeGuard<Functor>&& that) : f_(std::move(that.f_)), active_(that.active_) {
+ constexpr ScopeGuard(ScopeGuard<Functor>&& that) : f_(std::move(that.f_)), active_(that.active_) {
that.active_ = false;
}
@@ -48,7 +48,7 @@
void Disable() { active_ = false; }
- bool active() const { return active_; }
+ constexpr bool active() const { return active_; }
private:
template <typename Functor>