C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: extremely long compile time with large number of string literals
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-07-09 16:46:27


On Fri, 10 Jul 2020 at 00:34, Mandeep Sandhu
<mandeepsandhu.chd_at_[hidden]> wrote:
>
> >
> > Overload resolution. Try passing suffixed-string literals,
> >
> > const std::unordered_set<std::string> my_set ({"item1"s, "item2"s, ....});
>
> I tried creating UDL strings like you suggested (but with a space
> between the literal & s), but it doesn't compile for me.
>
> A simple program like:
> ...
> const unordered_set<string> myset ({ "a" s, "b" s, "c" s, });
> int main()
> {
> cout << "size of myset = " << myset.size() << endl;
> }
>
> Doesn't compile, I get the error:
> ...
> error: expected ‘}’ before ‘s’
> 7 | const unordered_set<string> myset ({ "a" s, "b" s, "c" s, });
>
> Maybe I'm doing it wrong (I haven't used UDLs before).

I have no idea why you put those spaces there. Removing them makes the
program compile.


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups