From 40df94841921e91d3f4b86bcbc1506495b9d316e Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Fri, 1 Mar 2019 17:58:09 -0800 Subject: [PATCH] Support C++11 in folly/IPAddress.h w.r.t. aligned_union Summary: [Folly] Support C++11 in `folly/IPAddress.h` w.r.t. `aligned_union` by avoiding `aligned_union_t`, which is C++14. Reviewed By: spalamarchuk, mengz0 Differential Revision: D14278604 fbshipit-source-id: 474ac0aa0110f4939d1042d334b69feb6b2644cb --- folly/IPAddress.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/folly/IPAddress.h b/folly/IPAddress.h index 18e03f69a7c..91e0f0249e4 100644 --- a/folly/IPAddress.h +++ b/folly/IPAddress.h @@ -20,8 +20,10 @@ #include #include #include +#include #include // std::pair +#include #include #include #include @@ -442,7 +444,10 @@ class IPAddress { [[noreturn]] void asV6Throw() const; typedef union IPAddressV46 { - std::aligned_union_t<0, IPAddressV4, IPAddressV6> storage; + std::aligned_storage< + constexpr_max(sizeof(IPAddressV4), sizeof(IPAddressV6)), + constexpr_max(alignof(IPAddressV4), alignof(IPAddressV6))>::type + storage; IPAddressV4 ipV4Addr; IPAddressV6 ipV6Addr; // default constructor