Merge "<string_view> is always available." into main
diff --git a/libutils/binder/include/utils/String8.h b/libutils/binder/include/utils/String8.h
index 4a23df7..404f8a0 100644
--- a/libutils/binder/include/utils/String8.h
+++ b/libutils/binder/include/utils/String8.h
@@ -19,6 +19,7 @@
#include <iostream>
#include <string>
+#include <string_view>
#include <utils/Errors.h>
#include <utils/Unicode.h>
@@ -27,11 +28,6 @@
#include <string.h> // for strcmp
#include <stdarg.h>
-#if __has_include(<string_view>)
-#include <string_view>
-#define HAS_STRING_VIEW
-#endif
-
#if __cplusplus >= 202002L
#include <compare>
#endif
@@ -53,9 +49,7 @@
String8(const String8& o);
explicit String8(const char* o);
explicit String8(const char* o, size_t numChars);
-#ifdef HAS_STRING_VIEW
explicit String8(std::string_view o);
-#endif
explicit String8(const String16& o);
explicit String8(const char16_t* o);
@@ -125,9 +119,7 @@
inline operator const char*() const;
-#ifdef HAS_STRING_VIEW
inline explicit operator std::string_view() const;
-#endif
char* lockBuffer(size_t size);
void unlockBuffer();
@@ -372,20 +364,15 @@
return mString;
}
-#ifdef HAS_STRING_VIEW
-
inline String8::String8(std::string_view o) : String8(o.data(), o.length()) { }
inline String8::operator std::string_view() const
{
return {mString, length()};
}
-#endif
} // namespace android
// ---------------------------------------------------------------------------
-#undef HAS_STRING_VIEW
-
#endif // ANDROID_STRING8_H