Displaying 8 results from an estimated 8 matches for "__builtin_strlen".
2016 Nov 25
5
RFC: Constructing StringRefs at compile time
...isn't portably
>> constexpr and std::char_traits<char>::length is only constexpr in
>> C++17.
>
> Why don't we just create our own traits class that has a constexpr length, and then we can switch over to the standard one when we switch to C++17?
GCC and Clang treat __builtin_strlen as constexpr.
MSVC 2015 doesn't support C++14 extended constexpr. I don't know how
well it optimises a recursive strlen.
This works as an optimisation for GCC and Clang, and doesn't make
things worse for MSVC:
/// Construct a string ref from a cstring.
LLVM_ATTRIBUTE_ALWAYS_...
2016 Nov 25
2
RFC: Constructing StringRefs at compile time
...expr and std::char_traits<char>::length is only constexpr in
> >> C++17.
> >
> > Why don't we just create our own traits class that has a constexpr
> length, and then we can switch over to the standard one when we switch to
> C++17?
>
> GCC and Clang treat __builtin_strlen as constexpr.
> MSVC 2015 doesn't support C++14 extended constexpr. I don't know how well
> it optimises a recursive strlen.
>
> This works as an optimisation for GCC and Clang, and doesn't make things
> worse for MSVC:
>
> /// Construct a string ref from a cst...
2016 Nov 28
5
RFC: Constructing StringRefs at compile time
...expr and std::char_traits<char>::length is only constexpr in
> >> C++17.
> >
> > Why don't we just create our own traits class that has a constexpr
> length, and then we can switch over to the standard one when we switch to
> C++17?
>
> GCC and Clang treat __builtin_strlen as constexpr.
> MSVC 2015 doesn't support C++14 extended constexpr. I don't know how well
> it optimises a recursive strlen.
>
> This works as an optimisation for GCC and Clang, and doesn't make things
> worse for MSVC:
>
> /// Construct a string ref from a cst...
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 29
4
RFC: Constructing StringRefs at compile time
On 29 November 2016 at 17:38, Zachary Turner <zturner at google.com> 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
>
2016 Nov 28
3
RFC: Constructing StringRefs at compile time
...expr and std::char_traits<char>::length is only constexpr in
> >> C++17.
> >
> > Why don't we just create our own traits class that has a constexpr
> length, and then we can switch over to the standard one when we switch to
> C++17?
>
> GCC and Clang treat __builtin_strlen as constexpr.
> MSVC 2015 doesn't support C++14 extended constexpr. I don't know how well
> it optimises a recursive strlen.
>
> This works as an optimisation for GCC and Clang, and doesn't make things
> worse for MSVC:
>
> /// Construct a string ref from a cst...
2016 Nov 28
3
RFC: Constructing StringRefs at compile time
...expr and std::char_traits<char>::length is only constexpr in
> >> C++17.
> >
> > Why don't we just create our own traits class that has a constexpr
> length, and then we can switch over to the standard one when we switch to
> C++17?
>
> GCC and Clang treat __builtin_strlen as constexpr.
> MSVC 2015 doesn't support C++14 extended constexpr. I don't know how well
> it optimises a recursive strlen.
>
> This works as an optimisation for GCC and Clang, and doesn't make things
> worse for MSVC:
>
> /// Construct a string ref from a cst...
2016 Nov 24
3
RFC: Constructing StringRefs at compile time
Hi all,
There is a desire to be able to create constexpr StringRefs to avoid
static initializers for global tables of/containing StringRefs.
Creating constexpr StringRefs isn't trivial as strlen isn't portably
constexpr and std::char_traits<char>::length is only constexpr in
C++17.
Alp Toker tried to create constexpr StringRefs for strings literals by
subclassing StringRef: