summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/StringView.h5
-rw-r--r--AK/Tests/TestStringView.cpp9
-rw-r--r--CMakeLists.txt4
-rw-r--r--Meta/Lagom/CMakeLists.txt2
4 files changed, 17 insertions, 3 deletions
diff --git a/AK/StringView.h b/AK/StringView.h
index 8d6192a795..1237e147b6 100644
--- a/AK/StringView.h
+++ b/AK/StringView.h
@@ -213,4 +213,9 @@ struct Traits<StringView> : public GenericTraits<String> {
}
+[[nodiscard]] ALWAYS_INLINE constexpr AK::StringView operator"" sv(const char* cstring, size_t length)
+{
+ return AK::StringView(cstring, length);
+}
+
using AK::StringView;
diff --git a/AK/Tests/TestStringView.cpp b/AK/Tests/TestStringView.cpp
index 56cf440720..a95be835bd 100644
--- a/AK/Tests/TestStringView.cpp
+++ b/AK/Tests/TestStringView.cpp
@@ -59,6 +59,15 @@ TEST_CASE(compare_views)
EXPECT_EQ(view1, "foo");
}
+TEST_CASE(string_view_literal_operator)
+{
+ StringView literal_view = "foo"sv;
+ String test_string = "foo";
+
+ EXPECT_EQ(literal_view.length(), test_string.length());
+ EXPECT_EQ(literal_view, test_string);
+}
+
TEST_CASE(starts_with)
{
String test_string = "ABCDEF";
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 30edc118cc..3d53990a12 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,9 +80,9 @@ else()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- add_compile_options(-fconcepts)
+ add_compile_options(-fconcepts -Wno-literal-suffix)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- add_compile_options(-Wno-overloaded-virtual)
+ add_compile_options(-Wno-overloaded-virtual -Wno-user-defined-literals)
endif()
if (ENABLE_ALL_THE_DEBUG_MACROS)
diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt
index 51739f72cd..44aa1ce8c8 100644
--- a/Meta/Lagom/CMakeLists.txt
+++ b/Meta/Lagom/CMakeLists.txt
@@ -9,7 +9,7 @@ endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -Wno-user-defined-literals")
if (ENABLE_ADDRESS_SANITIZER)
add_definitions(-fsanitize=address -fno-omit-frame-pointer)