mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-10-31 00:17:44 +08:00
Make StringRef borrow reference only when taking a pointer. (#91)
This commit is contained in:
parent
900ed256ae
commit
2723616dc8
@ -21,8 +21,8 @@ int wstring_width_cjk(const std::wstring&);
|
|||||||
/// references toward a shared representation.
|
/// references toward a shared representation.
|
||||||
class StringRef {
|
class StringRef {
|
||||||
public:
|
public:
|
||||||
StringRef(std::wstring& ref);
|
|
||||||
StringRef(std::wstring* ref);
|
StringRef(std::wstring* ref);
|
||||||
|
StringRef(std::wstring ref);
|
||||||
StringRef(const wchar_t* ref);
|
StringRef(const wchar_t* ref);
|
||||||
StringRef(const char* ref);
|
StringRef(const char* ref);
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ class StringRef {
|
|||||||
/// references toward shared representation.
|
/// references toward shared representation.
|
||||||
class ConstStringRef {
|
class ConstStringRef {
|
||||||
public:
|
public:
|
||||||
ConstStringRef(const std::wstring& ref);
|
|
||||||
ConstStringRef(const std::wstring* ref);
|
ConstStringRef(const std::wstring* ref);
|
||||||
|
ConstStringRef(std::wstring ref);
|
||||||
ConstStringRef(const wchar_t* ref);
|
ConstStringRef(const wchar_t* ref);
|
||||||
ConstStringRef(const char* ref);
|
ConstStringRef(const char* ref);
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ std::wstring to_wstring(const std::string& s) {
|
|||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
StringRef::StringRef(std::wstring& ref) : borrowed_(&ref) {}
|
|
||||||
StringRef::StringRef(std::wstring* ref) : borrowed_(ref) {}
|
StringRef::StringRef(std::wstring* ref) : borrowed_(ref) {}
|
||||||
|
StringRef::StringRef(std::wstring ref) : owned_(std::move(ref)) {}
|
||||||
StringRef::StringRef(const wchar_t* ref) : owned_(ref) {}
|
StringRef::StringRef(const wchar_t* ref) : owned_(ref) {}
|
||||||
StringRef::StringRef(const char* ref) : owned_(to_wstring(std::string(ref))) {}
|
StringRef::StringRef(const char* ref) : owned_(to_wstring(std::string(ref))) {}
|
||||||
std::wstring& StringRef::operator*() {
|
std::wstring& StringRef::operator*() {
|
||||||
@ -36,8 +36,8 @@ std::wstring* StringRef::operator->() {
|
|||||||
return borrowed_ ? borrowed_ : &owned_;
|
return borrowed_ ? borrowed_ : &owned_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstStringRef::ConstStringRef(const std::wstring& ref) : borrowed_(&ref) {}
|
|
||||||
ConstStringRef::ConstStringRef(const std::wstring* ref) : borrowed_(ref) {}
|
ConstStringRef::ConstStringRef(const std::wstring* ref) : borrowed_(ref) {}
|
||||||
|
ConstStringRef::ConstStringRef(std::wstring ref) : owned_(std::move(ref)) {}
|
||||||
ConstStringRef::ConstStringRef(const wchar_t* ref) : owned_(ref) {}
|
ConstStringRef::ConstStringRef(const wchar_t* ref) : owned_(ref) {}
|
||||||
ConstStringRef::ConstStringRef(const char* ref)
|
ConstStringRef::ConstStringRef(const char* ref)
|
||||||
: owned_(to_wstring(std::string(ref))) {}
|
: owned_(to_wstring(std::string(ref))) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user