Skip to content

Commit

Permalink
Support C++11 in folly/IPAddress.h w.r.t. aligned_union
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Mar 2, 2019
1 parent a99a9d3 commit 40df948
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion folly/IPAddress.h
Expand Up @@ -20,8 +20,10 @@
#include <iosfwd>
#include <memory>
#include <string>
#include <type_traits>
#include <utility> // std::pair

#include <folly/ConstexprMath.h>
#include <folly/IPAddressException.h>
#include <folly/IPAddressV4.h>
#include <folly/IPAddressV6.h>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 40df948

Please sign in to comment.