@@ -57,22 +57,24 @@ class TaggedUnionBase<KindHelper, Members,
57
57
58
58
TaggedUnionBase (Kind theKind) : TheKind(theKind) {}
59
59
60
+ template <typename T>
61
+ static constexpr const bool constructible =
62
+ TaggedUnionImpl::is_member_constructible<Members, T>();
63
+
60
64
public:
61
65
// / Construct the union with a value of the given type, which must
62
66
// / (ignoring references) be one of the declared members of the union.
63
67
template <class T >
64
68
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 = {}) {
68
71
using TargetType = TaggedUnionImpl::simplify_member_type<T>;
69
72
TheKind = StorageType::template kindForMember<TargetType>();
70
73
Storage.template emplace <TargetType>(TheKind, std::forward<T>(value));
71
74
}
72
75
73
76
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
76
78
operator =(T &&value) {
77
79
using TargetType = TaggedUnionImpl::simplify_member_type<T>;
78
80
TheKind = StorageType::template kindForMember<TargetType>();
@@ -155,12 +157,15 @@ class TaggedUnionBase<KindHelper, Members, /*NonTrivial*/ true, /*HasVoid*/ fals
155
157
156
158
TaggedUnionBase (typename super::Kind kind) : super(kind) {}
157
159
160
+ template <typename T>
161
+ static constexpr const bool constructible =
162
+ TaggedUnionImpl::is_member_constructible<Members, T>();
163
+
158
164
public:
159
165
template <class T >
160
166
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 = {})
164
169
: super(std::forward<T>(value)) {}
165
170
166
171
// We want to either define or delete all the special members.
@@ -236,12 +241,15 @@ class TaggedUnionBase<KindHelper, Members, NonTrivial, /*HasVoid*/ true>
236
241
return super::StorageType::template kindForMember<void >();
237
242
}
238
243
244
+ template <typename T>
245
+ static constexpr const bool constructible =
246
+ TaggedUnionImpl::is_member_constructible<Members, T>();
247
+
239
248
public:
240
249
template <class T >
241
250
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 = {})
245
253
: super(std::forward<T>(value)) {}
246
254
247
255
// / Construct the union in the empty state.
0 commit comments