On 31.05.23 09:07, Sami Varanka via Development wrote: > What is the recommended way for functions to take strings? Our QtGraphs > API takes in const QString & but is recommended way nowadays take in > QAnyStringView?
I doubt there's an accepted project-wide standard, yet, but as a rule of thumb that everyone might be able to agree on: If the function doesn't store the string as-is (=parses or pre-processes it), take by QAnyStringView, otherwise continue to take by QString cref. For very important APIs, there's the option to overload on - `const QString &` and/or `QString &&` - QAnyStringView In this case, the QString overloads have to be marked Q_WEAK_OVERLOAD to avoid ambiguous calls with certain argument types (`const char*`, `QByteArray`, etc). HTH, Marc -- Marc Mutz <marc.m...@qt.io> Principal Software Engineer The Qt Company Erich-Thilo-Str. 10 12489 Berlin, Germany www.qt.io Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development