forked from qt-creator/qt-creator
Clang: Add equal operators for ClangString
Converting them in a Utf8String in an inner loop can be quite heavy. Change-Id: I4f2ccde47a6e3ca08ed054462eb7772ded9e55c9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Nikolai Kosjar
parent
f22bd9dc4c
commit
43d6726c70
@@ -85,7 +85,38 @@ public:
|
||||
return cxString.data == nullptr;
|
||||
}
|
||||
|
||||
friend bool operator==(const ClangString &first, const ClangString &second)
|
||||
{
|
||||
return std::strcmp(first.cString(), second.cString()) == 0;
|
||||
}
|
||||
|
||||
template<std::size_t Size>
|
||||
friend bool operator==(const ClangString &first, const char(&second)[Size])
|
||||
{
|
||||
return std::strncmp(first.cString(), second, Size) == 0; // Size includes \0
|
||||
}
|
||||
|
||||
template<std::size_t Size>
|
||||
friend bool operator==(const char(&first)[Size], const ClangString &second)
|
||||
{
|
||||
return second == first;
|
||||
}
|
||||
|
||||
template<typename Type,
|
||||
typename = typename std::enable_if<std::is_pointer<Type>::value>::type
|
||||
>
|
||||
friend bool operator==(const ClangString &first, Type second)
|
||||
{
|
||||
return std::strcmp(first.cString(), second) == 0;
|
||||
}
|
||||
|
||||
template<typename Type,
|
||||
typename = typename std::enable_if<std::is_pointer<Type>::value>::type
|
||||
>
|
||||
friend bool operator==(Type first, const ClangString &second)
|
||||
{
|
||||
return second == first;
|
||||
}
|
||||
|
||||
private:
|
||||
CXString cxString;
|
||||
|
||||
Reference in New Issue
Block a user