Em segunda-feira, 6 de março de 2017, às 12:45:53 CET, Daniel Krügler
escreveu:
> 2017-03-06 12:27 GMT+01:00 Thiago Macieira <
thi...@macieira.org>:
> > 1) I do expect other functions inherited from C to become constexpr, like
> > abs(), so we shouldn't be against doing this.
>
> I'm not seeing abs() yet to be constexpr, so this would depend on the
> success of such a proposal. Could you refer to the paper that you were
> (presumably) thinking of?
Sorry if I misled you: there is no such paper. My point is that std::abs
should be constexpr too. It's also an exampe of function that differs from C:
C's abs takes int; C++'s is overloaded on all integer and floating point types.
> > 2) people know strlen() a lot more than std::char_traits<char>::length. I
> > didn't know it existed until I went searching, an hour ago.
>
> This is IMO not a very sufficient reason, because people can learn the
> difference.
There shouldn't be a difference and in turn that should be sufficient reason.
> > 3) and this is my agenda: strlen is SIMD-optimised,
> > std::char_traits<char>::length isn't.
>
> Well, since SIMS optimization is not part of the standard, this seems
> to be QoI anyway. Why not complaining to the vendor of your library to
> ensure that std::char_traits<char>::length becomes SIMD-optimized,
> too?
Because you can't write SIMD code in constexpr functions. We need a way to
determine whether the function is being run constexprly or not.
I was playing with using compiler extensions, but have yet to manage it. See
https://godbolt.org/g/Dx5FKb
for an attempt (untested) with GCC builtins. I can't use the official functions
(not constexpr) and I can't write asm("") in that function...
> Note that I don't want to judge your request as use-less. I'm only
> asking these questions, because similar questions will presumably be
> asked when the Committee would inspect a corresponding paper.