"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "include/swift/Basic/TaggedUnion.h" between
swift-swift-5.8-RELEASE.tar.gz and swift-swift-5.8.1-RELEASE.tar.gz

About: Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns (developed by Apple).

TaggedUnion.h  (swift-swift-5.8-RELEASE):TaggedUnion.h  (swift-swift-5.8.1-RELEASE)
skipping to change at line 60 skipping to change at line 60
/*NonTrivial*/ false, /*NonTrivial*/ false,
/*HasVoid*/ false> { /*HasVoid*/ false> {
protected: protected:
using StorageType = SimpleExternalUnionBase<KindHelper, Members>; using StorageType = SimpleExternalUnionBase<KindHelper, Members>;
using Kind = typename KindHelper::Kind; using Kind = typename KindHelper::Kind;
StorageType Storage; StorageType Storage;
Kind TheKind; Kind TheKind;
TaggedUnionBase(Kind theKind) : TheKind(theKind) {} TaggedUnionBase(Kind theKind) : TheKind(theKind) {}
template <typename T>
static constexpr const bool constructible =
TaggedUnionImpl::is_member_constructible<Members, T>();
public: public:
/// Construct the union with a value of the given type, which must /// Construct the union with a value of the given type, which must
/// (ignoring references) be one of the declared members of the union. /// (ignoring references) be one of the declared members of the union.
template <class T> template <class T>
TaggedUnionBase(T &&value, TaggedUnionBase(T &&value,
typename std::enable_if< typename std::enable_if<constructible<T>,
TaggedUnionImpl::is_member_constructible<Members, T>(), TaggedUnionImpl::Empty>::type = {}) {
TaggedUnionImpl::Empty>::type = {}) {
using TargetType = TaggedUnionImpl::simplify_member_type<T>; using TargetType = TaggedUnionImpl::simplify_member_type<T>;
TheKind = StorageType::template kindForMember<TargetType>(); TheKind = StorageType::template kindForMember<TargetType>();
Storage.template emplace<TargetType>(TheKind, std::forward<T>(value)); Storage.template emplace<TargetType>(TheKind, std::forward<T>(value));
} }
template <class T> template <class T>
typename std::enable_if<TaggedUnionImpl::is_member_constructible<Members, T>() typename std::enable_if<constructible<T>, TaggedUnionBase &>::type
,
TaggedUnionBase &>::type
operator=(T &&value) { operator=(T &&value) {
using TargetType = TaggedUnionImpl::simplify_member_type<T>; using TargetType = TaggedUnionImpl::simplify_member_type<T>;
TheKind = StorageType::template kindForMember<TargetType>(); TheKind = StorageType::template kindForMember<TargetType>();
Storage.template emplace<TargetType>(TheKind, std::forward<T>(value)); Storage.template emplace<TargetType>(TheKind, std::forward<T>(value));
return *this; return *this;
} }
/// Replace the current value in the union with a value of the given /// Replace the current value in the union with a value of the given
/// type, which must be one of the declared members of the union. /// type, which must be one of the declared members of the union.
/// ///
skipping to change at line 158 skipping to change at line 160
class TaggedUnionBase<KindHelper, Members, /*NonTrivial*/ true, /*HasVoid*/ fals e> class TaggedUnionBase<KindHelper, Members, /*NonTrivial*/ true, /*HasVoid*/ fals e>
: public TaggedUnionBase<KindHelper, Members, false, false> { : public TaggedUnionBase<KindHelper, Members, false, false> {
using super = TaggedUnionBase<KindHelper, Members, false, false>; using super = TaggedUnionBase<KindHelper, Members, false, false>;
protected: protected:
using super::Storage; using super::Storage;
using super::TheKind; using super::TheKind;
TaggedUnionBase(typename super::Kind kind) : super(kind) {} TaggedUnionBase(typename super::Kind kind) : super(kind) {}
template <typename T>
static constexpr const bool constructible =
TaggedUnionImpl::is_member_constructible<Members, T>();
public: public:
template <class T> template <class T>
TaggedUnionBase(T &&value, TaggedUnionBase(T &&value,
typename std::enable_if< typename std::enable_if<constructible<T>,
TaggedUnionImpl::is_member_constructible<Members, T>(), TaggedUnionImpl::Empty>::type = {})
TaggedUnionImpl::Empty>::type = {})
: super(std::forward<T>(value)) {} : super(std::forward<T>(value)) {}
// We want to either define or delete all the special members. // We want to either define or delete all the special members.
// C++ does not provide a direct way to conditionally delete a // C++ does not provide a direct way to conditionally delete a
// function. enable_if doesn't work, for several reasons: you can't // function. enable_if doesn't work, for several reasons: you can't
// make an enable_if condition depend only on a property of the // make an enable_if condition depend only on a property of the
// enclosing class template (because all member function signatures // enclosing class template (because all member function signatures
// must successfully instantiate as part of instantiating the class // must successfully instantiate as part of instantiating the class
// template; this is not covered by SFINAE), and you can't make the // template; this is not covered by SFINAE), and you can't make the
// special member itself a template (because then it's not a special // special member itself a template (because then it's not a special
skipping to change at line 239 skipping to change at line 244
using super = TaggedUnionBase<KindHelper, Members, NonTrivial, false>; using super = TaggedUnionBase<KindHelper, Members, NonTrivial, false>;
protected: protected:
using super::Storage; using super::Storage;
using super::TheKind; using super::TheKind;
static constexpr typename super::Kind kindForVoid() { static constexpr typename super::Kind kindForVoid() {
return super::StorageType::template kindForMember<void>(); return super::StorageType::template kindForMember<void>();
} }
template <typename T>
static constexpr const bool constructible =
TaggedUnionImpl::is_member_constructible<Members, T>();
public: public:
template <class T> template <class T>
TaggedUnionBase(T &&value, TaggedUnionBase(T &&value,
typename std::enable_if< typename std::enable_if<constructible<T>,
TaggedUnionImpl::is_member_constructible<Members, T>(), TaggedUnionImpl::Empty>::type = {})
TaggedUnionImpl::Empty>::type = {})
: super(std::forward<T>(value)) {} : super(std::forward<T>(value)) {}
/// Construct the union in the empty state. /// Construct the union in the empty state.
TaggedUnionBase() : super(kindForVoid()) {} TaggedUnionBase() : super(kindForVoid()) {}
/// Test whether the union is in the empty state. /// Test whether the union is in the empty state.
bool empty() const { bool empty() const {
return TheKind == kindForVoid(); return TheKind == kindForVoid();
} }
 End of changes. 7 change blocks. 
12 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)