From 46f74dc249f6f254ba650a29dcc411da859d18f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 19 Feb 2022 22:11:22 +0100 Subject: [PATCH] Utility: make IsStringLike recognize C++17 std::string_view. Debug used to print it as a numeric container, which isn't really wanted. It can be thought of as a breaking change however, and so it's listed as such. --- doc/corrade-changelog.dox | 6 ++++++ src/Corrade/Utility/TypeTraits.h | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/corrade-changelog.dox b/doc/corrade-changelog.dox index 1e3aa7926..ecad3cd50 100644 --- a/doc/corrade-changelog.dox +++ b/doc/corrade-changelog.dox @@ -214,6 +214,8 @@ namespace Corrade { @ref Containers::String using @ref Utility::format() - Creating an empty path with @ref Utility::Directory::mkpath() now succeeds because it makes no sense to fail for such case +- @ref Utility::IsStringLike now recognizes also C++17 @ref std::string_view + by checking for a @cpp substr() @ce member instead of @cpp c_str() @ce - The @ref CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE macro is now defined on Emscripten always, because even if it's @cpp long double @ce is 80-bit sometimes, it doesn't actually have the precision of a 80-bit @@ -373,6 +375,10 @@ namespace Corrade { @ref Containers::MutableStringView instead of @ref Containers::ArrayView. The types are however implicitly convertible and thus breakages are not expected in majority of existing code. +- Printing a C++17 @ref std::string_view with @ref Utility::Debug now + requires the @ref Corrade/Utility/DebugStlStringView.h include. Before it + was printed as a numeric container due to @ref Utility::IsStringLike not + recognizing it. @subsection corrade-changelog-latest-documentation Documentation diff --git a/src/Corrade/Utility/TypeTraits.h b/src/Corrade/Utility/TypeTraits.h index 6db7af5a5..f687afc9f 100644 --- a/src/Corrade/Utility/TypeTraits.h +++ b/src/Corrade/Utility/TypeTraits.h @@ -191,7 +191,7 @@ namespace Implementation { CORRADE_HAS_TYPE(HasMemberEnd, decltype(std::declval().end())); CORRADE_HAS_TYPE(HasBegin, decltype(begin(std::declval()))); CORRADE_HAS_TYPE(HasEnd, decltype(end(std::declval()))); - CORRADE_HAS_TYPE(HasMemberCStr, decltype(std::declval().c_str())); + CORRADE_HAS_TYPE(HasMemberSubstr, decltype(std::declval().substr())); } /** @@ -221,11 +221,11 @@ template using IsIterable = std::integral_constant using IsStringLike = std::integral_constant::value || std::is_same::type, Containers::StringView>::value || std::is_same::type, Containers::MutableStringView>::value || std::is_same::type, Containers::String>::value + Implementation::HasMemberSubstr::value || std::is_same::type, Containers::StringView>::value || std::is_same::type, Containers::MutableStringView>::value || std::is_same::type, Containers::String>::value #else implementation-specific #endif