Displaying 5 results from an estimated 5 matches for "x_string_ref_literal".
2016 Nov 29
2
RFC: Constructing StringRefs at compile time
...gt; the
> >> thread, and if I'm not mistaken I see this:
> >
> > That's a different suggestion.
> >
> >> That said, what did you think about my other proposal of the
> complicated UDL
> >> with macro?
> >>
> >> #define LIT(x) x_string_ref_literal
> >> constexpr StringRef Strings[] = {LIT("a"), LIT("b"), LIT("c")};
> >
> > Why bother with the UDL?
> > #define LIT(x) StringRef((x), sizeof(x)-1)
> >
>
> There is subtlety though, it changes the result for: LIT(“hello\0world”)....
2016 Nov 29
4
RFC: Constructing StringRefs at compile time
...wrote:
> I see, but I looked over your proposed implementation from earlier in the
> thread, and if I'm not mistaken I see this:
That's a different suggestion.
> That said, what did you think about my other proposal of the complicated UDL
> with macro?
>
> #define LIT(x) x_string_ref_literal
> constexpr StringRef Strings[] = {LIT("a"), LIT("b"), LIT("c")};
Why bother with the UDL?
#define LIT(x) StringRef((x), sizeof(x)-1)
--
Malcolm Parsons
2016 Nov 29
2
RFC: Constructing StringRefs at compile time
On 29 November 2016 at 16:18, Zachary Turner <zturner at google.com> wrote:
> I don't like the llvm_strlen approach as it is incompatible with
> std::string_view which we may eventually move to.
In what way is it incompatible?
constexpr StringRef(const char* s) : Data(s), Length(llvm_strlen(s)) {}
is equivalent to
constexpr string_view(const char* s) : Data(s),
2016 Nov 28
3
RFC: Constructing StringRefs at compile time
...t this UDL be used
only in global constructors. One idea to help "enforce" this policy would
be to give the UDL a ridiculously convoluted name, like
`string_ref_literal`, so that one would have to write
"foo"_string_ref_literal, and then provide a macro like `#define LITERAL(x)
x_string_ref_literal`, so that the user writes `StringRef s[] = {
LITERAL("a"), LITERAL("b") }; I'm not sure if that's better or worse than
`StringRef s[] = { "a"_sr, "b"_sr };`, but at least it's greppable this way.
2) Don't allow global tables of StringRefs....
2016 Nov 28
3
RFC: Constructing StringRefs at compile time
On Mon, Nov 28, 2016 at 11:01 AM Mehdi Amini <mehdi.amini at apple.com> wrote:
> On Nov 28, 2016, at 9:47 AM, David Blaikie via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
> OK - good to know. (not sure we're talking about pessimizing it - just not
> adding a new/possible optimization, to be clear)
>
>
> This does not seem that clear to me. The