From b229e1a548855e6815f937f84e2c873f358016b9 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Thu, 27 Jul 2017 09:20:04 -0700 Subject: [PATCH] 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 --- folly/Optional.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 -- 2.34.1