Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

https://isocpp.org/wiki/faq/big-picture -- possible typo

38 views
Skip to first unread message

Paul

unread,
Feb 7, 2020, 9:47:04 AM2/7/20
to
In https://isocpp.org/wiki/faq/big-picture it gives as an example code snippet:

auto p = find(begin(vs), end(vs), "Grail"s);
// vector<string> vs; p is vector<string>::iterator

Is the s at the end of "Grail" a typo? I can't understand it or get it to compile.
Without that s it makes perfect sense.

Thanks a lot,

Paul

Öö Tiib

unread,
Feb 7, 2020, 10:06:49 AM2/7/20
to
On Friday, 7 February 2020 16:47:04 UTC+2, Paul wrote:
> In https://isocpp.org/wiki/faq/big-picture it gives as an example code snippet:
>
> auto p = find(begin(vs), end(vs), "Grail"s);
> // vector<string> vs; p is vector<string>::iterator
>
> Is the s at the end of "Grail" a typo?

No.
https://en.cppreference.com/w/cpp/string/basic_string/operator%22%22s

> I can't understand it or get it to compile.
> Without that s it makes perfect sense.

You need to have:

using namespace std::string_literals;


Or:

using std::string_literals::operator ""s;

Within current namespace.

Tony Mc

unread,
Feb 8, 2020, 6:34:55 AM2/8/20
to
It means that "Grail"s is a std::string literal rather than a C-style
const char * literal. It comes from the std::string_literals namespace
and was introduced with C++14.

Tony

0 new messages