Files
swift-mirror/test/Interop/Cxx/stdlib/Inputs/std-string.h
Egor Zhdan 84e7f82363 Reapply "[ConstraintSystem] C++ Interop: Binding a string literal to std.string shouldn't increase the score"
This reverts commit 6852bc9834.

In addition to the original change, this makes sure that C++ `std::string` and Swift `String` are given distinct score, in order to prevent ambiguity which was causing build failures in some projects.

rdar://158439395
2025-12-09 12:55:18 +00:00

25 lines
567 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;
}
StringBox operator+(const StringBox &rhs) const {
return {value + rhs.value};
}
};