Nigel Tao
2018-11-14 06:06:22 UTC
I have a static string constant:
class Foo {
// Etc.
// An empty string that some methods return a reference to.
static const std::string empty_string_;
}
https://chromium-review.googlesource.com/c/chromium/src/+/1335071/1/chrome/services/app_service/public/cpp/app_update.h#59
that I use because a method wants to return a "const std::string&":
const std::string& AppUpdate::Name() const {
// Etc.
return empty_string_;
}
https://chromium-review.googlesource.com/c/chromium/src/+/1335071/1/chrome/services/app_service/public/cpp/app_update.cc#66
cpplint complains with "For a static/global string constant, use a C
style string instead: "const char AppUpdate::empty_string_[]".
[runtime/string] [4]"
but a C style string doesn't work here. I don't want a particular
sequence of characters. I want a fallback *value* (specifically of
type std::string) that I can return a const reference to, that the
caller can use *after the function returns*, but the caller also
shouldn't destroy that std::string.
What should I do instead, to please cpplint?
class Foo {
// Etc.
// An empty string that some methods return a reference to.
static const std::string empty_string_;
}
https://chromium-review.googlesource.com/c/chromium/src/+/1335071/1/chrome/services/app_service/public/cpp/app_update.h#59
that I use because a method wants to return a "const std::string&":
const std::string& AppUpdate::Name() const {
// Etc.
return empty_string_;
}
https://chromium-review.googlesource.com/c/chromium/src/+/1335071/1/chrome/services/app_service/public/cpp/app_update.cc#66
cpplint complains with "For a static/global string constant, use a C
style string instead: "const char AppUpdate::empty_string_[]".
[runtime/string] [4]"
but a C style string doesn't work here. I don't want a particular
sequence of characters. I want a fallback *value* (specifically of
type std::string) that I can return a const reference to, that the
caller can use *after the function returns*, but the caller also
shouldn't destroy that std::string.
What should I do instead, to please cpplint?
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAEdON6ZirDoNFPCbkkxwjBy4y_7Kb18Do_Kc3vx2MGA9H4ZKHw%40mail.gmail.com.
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAEdON6ZirDoNFPCbkkxwjBy4y_7Kb18Do_Kc3vx2MGA9H4ZKHw%40mail.gmail.com.