1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

Revert "PR51018: Disallow explicit construction of StringRef from SmallString due to ambiguity in C++23"

This reverts commit e2d30846327c7ec5cc9d2a46aa9bcd9c2c4eff93.

MSVC doesn't seem to resolve the intended ambiguity in implicit
conversion contexts correctly: https://godbolt.org/z/ee16aqv4v
This commit is contained in:
David Blaikie 2021-07-08 13:46:36 -07:00
parent 0a392cfdcf
commit 54e05361bc

View File

@ -19,22 +19,10 @@
namespace llvm {
namespace impl {
template <typename T> struct SmallStringConversionHelper1 {
operator StringRef() const { return static_cast<const T *>(this)->str(); }
};
struct SmallStringConversionHelper2 {
explicit operator StringRef() const = delete;
};
} // namespace impl
/// SmallString - A SmallString is just a SmallVector with methods and accessors
/// that make it work better as a string (e.g. operator+ etc).
template <unsigned InternalLen>
class SmallString
: public SmallVector<char, InternalLen>,
public impl::SmallStringConversionHelper1<SmallString<InternalLen>>,
public impl::SmallStringConversionHelper2 {
template<unsigned InternalLen>
class SmallString : public SmallVector<char, InternalLen> {
public:
/// Default ctor - Initialize to empty.
SmallString() = default;
@ -278,6 +266,7 @@ public:
}
/// Implicit conversion to StringRef.
operator StringRef() const { return str(); }
explicit operator std::string() const {
return std::string(this->data(), this->size());