From: Michael Lee Date: Thu, 27 Jul 2017 16:20:04 +0000 (-0700) Subject: Switch to folly/Optional.h to use std::aligned_storage X-Git-Tag: v2017.07.31.00~18 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b229e1a548855e6815f937f84e2c873f358016b9;p=folly.git Switch to folly/Optional.h to use std::aligned_storage Summary: Older versions of libc++ do not support `std::aligned_storage_t`, switch to something more widely supported. Differential Revision: D5506449 fbshipit-source-id: 3f5cf5dddf00bda76d4f16cfd4d8944ee5f1ba55 --- diff --git a/folly/Optional.h b/folly/Optional.h index cdf05201..f8d39cb8 100644 --- a/folly/Optional.h +++ b/folly/Optional.h @@ -285,7 +285,8 @@ class Optional { struct StorageTriviallyDestructible { protected: bool hasValue_; - std::aligned_storage_t value_[1]; + typename std::aligned_storage::type + value_[1]; public: StorageTriviallyDestructible() : hasValue_{false} {} @@ -297,7 +298,8 @@ class Optional { struct StorageNonTriviallyDestructible { protected: bool hasValue_; - std::aligned_storage_t value_[1]; + typename std::aligned_storage::type + value_[1]; public: StorageNonTriviallyDestructible() : hasValue_{false} {} @@ -313,10 +315,10 @@ class Optional { } }; - struct Storage : std::conditional_t< + struct Storage : std::conditional< std::is_trivially_destructible::value, StorageTriviallyDestructible, - StorageNonTriviallyDestructible> { + StorageNonTriviallyDestructible>::type { bool hasValue() const { return this->hasValue_; } @@ -371,7 +373,7 @@ void swap(Optional& a, Optional& b) { } } -template >> +template ::type>> Opt make_optional(T&& v) { return Opt(std::forward(v)); } @@ -471,7 +473,7 @@ struct hash> { if (!obj.hasValue()) { return 0; } - return hash>()(*obj); + return hash::type>()(*obj); } }; FOLLY_NAMESPACE_STD_END