mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Prevent SimpleGeneratorRef from being used as the copy constructor.
This commit is contained in:
@@ -146,6 +146,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
namespace generator_details {
|
||||
template <class T> struct is_simple_generator_ref;
|
||||
}
|
||||
|
||||
/// An abstracting reference to an existing generator.
|
||||
///
|
||||
/// The implementation of this type holds the reference to the existing
|
||||
@@ -182,7 +186,8 @@ public:
|
||||
constexpr SimpleGeneratorRef() : vtable(nullptr), pointer(nullptr) {}
|
||||
|
||||
template <class G>
|
||||
constexpr SimpleGeneratorRef(G &generator)
|
||||
constexpr SimpleGeneratorRef(G &generator,
|
||||
typename std::enable_if<!generator_details::is_simple_generator_ref<G>::value, bool>::type = false)
|
||||
: vtable(&VTableImpl<G>::vtable), pointer(&generator) {}
|
||||
|
||||
/// Test whether this generator ref was initialized with a
|
||||
@@ -212,6 +217,19 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
namespace generator_details {
|
||||
|
||||
template <class T>
|
||||
struct is_simple_generator_ref<SimpleGeneratorRef<T>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
template <class T>
|
||||
struct is_simple_generator_ref {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user