include/o3tl/string_view.hxx | 8 ++++++++ 1 file changed, 8 insertions(+)
New commits: commit d7480ed72d225ee1b2b9a6ec996eeeb7a18c98a8 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Apr 14 23:05:42 2022 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Apr 15 08:39:01 2022 +0200 Add some clarifying comments for o3tl::getToken overloads Change-Id: Ia81b11b659f6045f9e474b3a32b72e2c5242a80b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133057 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx index 903cc5ced758..2438500768fe 100644 --- a/include/o3tl/string_view.hxx +++ b/include/o3tl/string_view.hxx @@ -74,6 +74,11 @@ inline std::basic_string_view<charT, traits> getToken(std::basic_string_view<cha } return t; } +// The following two overloads prevent overload resolution mistakes that would occur with their +// template counterpart, when sv is of a type that is implicitly convertible to basic_string_view +// (like OString or OUString), in which case overload resolution would erroneously choose the +// three-argument overloads (taking sv, nToken, cTok) from the second set of +// o3tl::getToken overloads below: inline std::string_view getToken(std::string_view sv, char delimiter, std::size_t& position) { return getToken<char>(sv, delimiter, position); @@ -133,6 +138,9 @@ inline std::basic_string_view<charT, traits> getToken(std::basic_string_view<cha rnIndex = -1; return std::basic_string_view<charT, traits>(); } +// The following two overloads prevent deduction failures that would occur with their template +// counterpart, when sv is of a type that is implicitly convertible to basic_string_view (like +// OString or OUString): inline std::string_view getToken(std::string_view sv, sal_Int32 nToken, char cTok, sal_Int32& rnIndex) {