@@ -57,22 +57,24 @@ class TaggedUnionBase<KindHelper, Members,
5757
5858 TaggedUnionBase (Kind theKind) : TheKind(theKind) {}
5959
60+ template <typename T>
61+ static constexpr const bool constructible =
62+ TaggedUnionImpl::is_member_constructible<Members, T>();
63+
6064public:
6165 // / Construct the union with a value of the given type, which must
6266 // / (ignoring references) be one of the declared members of the union.
6367 template <class T >
6468 TaggedUnionBase (T &&value,
65- typename std::enable_if<
66- TaggedUnionImpl::is_member_constructible<Members, T>(),
67- TaggedUnionImpl::Empty>::type = {}) {
69+ typename std::enable_if<constructible<T>,
70+ TaggedUnionImpl::Empty>::type = {}) {
6871 using TargetType = TaggedUnionImpl::simplify_member_type<T>;
6972 TheKind = StorageType::template kindForMember<TargetType>();
7073 Storage.template emplace <TargetType>(TheKind, std::forward<T>(value));
7174 }
7275
7376 template <class T >
74- typename std::enable_if<TaggedUnionImpl::is_member_constructible<Members, T>(),
75- TaggedUnionBase &>::type
77+ typename std::enable_if<constructible<T>, TaggedUnionBase &>::type
7678 operator =(T &&value) {
7779 using TargetType = TaggedUnionImpl::simplify_member_type<T>;
7880 TheKind = StorageType::template kindForMember<TargetType>();
@@ -155,12 +157,15 @@ class TaggedUnionBase<KindHelper, Members, /*NonTrivial*/ true, /*HasVoid*/ fals
155157
156158 TaggedUnionBase (typename super::Kind kind) : super(kind) {}
157159
160+ template <typename T>
161+ static constexpr const bool constructible =
162+ TaggedUnionImpl::is_member_constructible<Members, T>();
163+
158164public:
159165 template <class T >
160166 TaggedUnionBase (T &&value,
161- typename std::enable_if<
162- TaggedUnionImpl::is_member_constructible<Members, T>(),
163- TaggedUnionImpl::Empty>::type = {})
167+ typename std::enable_if<constructible<T>,
168+ TaggedUnionImpl::Empty>::type = {})
164169 : super(std::forward<T>(value)) {}
165170
166171 // We want to either define or delete all the special members.
@@ -236,12 +241,15 @@ class TaggedUnionBase<KindHelper, Members, NonTrivial, /*HasVoid*/ true>
236241 return super::StorageType::template kindForMember<void >();
237242 }
238243
244+ template <typename T>
245+ static constexpr const bool constructible =
246+ TaggedUnionImpl::is_member_constructible<Members, T>();
247+
239248public:
240249 template <class T >
241250 TaggedUnionBase (T &&value,
242- typename std::enable_if<
243- TaggedUnionImpl::is_member_constructible<Members, T>(),
244- TaggedUnionImpl::Empty>::type = {})
251+ typename std::enable_if<constructible<T>,
252+ TaggedUnionImpl::Empty>::type = {})
245253 : super(std::forward<T>(value)) {}
246254
247255 // / Construct the union in the empty state.
0 commit comments