Files
swift-mirror/test/Interop/Cxx/stdlib/Inputs/std-string.h
Pavel Yaskevich cd9c37cac6 [ConstraintSystem] C++ Interop: Binding a string literal to std.string shouldn't increase the score
Since this is a C++ stdlib type we need make sure that any overloads
that use it are preferred over custom types that also conform to
`ExpressibleByStringLiteral` when argument is a string literal.

This is important for operators like `==` which could be heterogenous
and have a custom C++ type that conforms to `ExpressibleByStringLiteral`
on either side together with `std.string` i.e.
`==(std.string, const CustomString &)`, such overloads should only
be selected if argument passed to `CustomString` is non-literal because
literals are convered by a stdlib `==(std.string, std.string)` overload.
2025-07-24 14:08:15 -07:00

21 lines
478 B
C++

#include <string>
struct HasMethodThatReturnsString {
int value = 111;
std::string getString() const { return std::to_string(value); }
};
inline std::string takesStringWithDefaultArg(std::string s = "abc") { return s; }
struct StringBox {
std::string value;
friend bool operator==(const StringBox &lhs, const std::string &rhs) {
return lhs.value == rhs;
}
friend bool operator==(const std::string &lhs, const StringBox &rhs) {
return rhs == lhs;
}
};