X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FIndestructible.h;h=ad1d21cbfeb3fcf06139215d385d69e6930fd64f;hb=61fbd6698139d3f797401da6350371c7afc4030c;hp=285d9ed6a6d3529850de5ca31612aa5d3dcf9a36;hpb=8f22c4e3ae765fa8b631c07ffa90dc4ba1aff279;p=folly.git diff --git a/folly/Indestructible.h b/folly/Indestructible.h index 285d9ed6..ad1d21cb 100644 --- a/folly/Indestructible.h +++ b/folly/Indestructible.h @@ -17,7 +17,6 @@ #pragma once #include -#include #include namespace folly { @@ -64,7 +63,7 @@ class Indestructible final { template ()...))> explicit constexpr Indestructible(Args&&... args) noexcept( - std::is_nothrow_constructible::value) + noexcept(T(std::declval()...))) : storage_(std::forward(args)...) {} ~Indestructible() = default; @@ -73,31 +72,31 @@ class Indestructible final { Indestructible& operator=(Indestructible const&) = delete; Indestructible(Indestructible&& other) noexcept( - std::is_nothrow_move_constructible::value) + noexcept(T(std::declval()))) : storage_(std::move(other.storage_.value)) { other.erased_ = true; } Indestructible& operator=(Indestructible&& other) noexcept( - std::is_nothrow_move_assignable::value) { + noexcept(T(std::declval()))) { storage_.value = std::move(other.storage_.value); other.erased_ = true; } - T* get() { + T* get() noexcept { check(); return &storage_.value; } - T const* get() const { + T const* get() const noexcept { check(); return &storage_.value; } - T& operator*() { return *get(); } - T const& operator*() const { return *get(); } - T* operator->() { return get(); } - T const* operator->() const { return get(); } + T& operator*() noexcept { return *get(); } + T const& operator*() const noexcept { return *get(); } + T* operator->() noexcept { return get(); } + T const* operator->() const noexcept { return get(); } private: - void check() const { + void check() const noexcept { assert(!erased_); } @@ -110,7 +109,8 @@ class Indestructible final { template < typename... Args, typename = decltype(T(std::declval()...))> - explicit constexpr Storage(Args&&... args) + explicit constexpr Storage(Args&&... args) noexcept( + noexcept(T(std::declval()...))) : value(std::forward(args)...) {} ~Storage() {}