From c484e2caa8fcbc9b3d362b25e981122ba0497544 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 4 May 2017 23:43:22 -0700 Subject: [PATCH] Add full noexcept annotations to Indestructible Summary: [Folly] Add full `noexcept` annotations to `Indestructible`. And do it without requiring ``. Reviewed By: Orvid Differential Revision: D4999243 fbshipit-source-id: f3521237ef4d03d2b187e9ebd6d0c90887872c42 --- folly/Indestructible.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) 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() {} -- 2.34.1