Why are operator?: overloads not allowed in C++? See, basically every
operator in C++ is overloadable. Sure, you can do stupid things with such
power, but that’s a general problem with humans that have power. C++ gives
power to programmers, we need to use it wisely. Apparently operator?: is not
overloadable because: “There is no fundamental reason to disallow overloading
of ?:. I just didn’t see the need to introduce the special case of
overloading a ternary operator. Note that a function overloading
expr1?expr2:expr3 would not be able to guarantee that only one of expr2 and
expr3 was executed.” [Stroustrup: C++ Style and Technique
FAQ]
Making the C++ conditional operator overloadable
Vectorized conversion from UTF-8 using stdx::simd
Bob Steagall presented his high-speed UTF-8
conversion at CppCon and C++Now
where he showed that his approach outperformed most existing conversion
algorithms. For some extra speed, he implemented a function for converting
ASCII to char16_t/char32_t using SSE intrinsics. This latter part got me
hooked, because:
stdx::simd(my contribution to the Parallelism TS 2; note that I usenamespace stdx = std::experimental, because the latter is just way too long.) was just sent off for publication by the C++ committee and should have made reliance on intrinsics unnecessary.- I had no prior experience with vectorizing string operations (which is one of the reasons my previous vector types library Vc didn’t have 8-bit integer support). I was curious, how hard can it be?
- Bob’s presentation made it look like one needs access to special instructions
like
movmskbto get good performance. - Scalability to different vector widths is unclear. The SSE intrinsics certainly won’t scale. But how much can performance actually scale, knowing that the larger the vector, the lower the chance the full vector of chars is only made up of ASCII?
- And what about newer ISA extensions such as SSE4.1 which adds instructions
for converting
unsigned chartoshortorint? Will it help? - Most important to me, can the code be more readable and portable and at least as fast at the same time?
- And is there a chance for vectorization of non-ASCII code point conversions?
Shortcuts for WG21 content
Since at least KDE 2, the runner (krunner - per default on Alt-F2) supports
configurable prefixes that resolve to a URL that is then opened like
kioclient5 exec would open them. I created the following shortcuts:
Optimizing std::hypot for simd arguments
Do you know about std::hypot(a, b) and std::hypot(a, b, c)? (The 3-argument
overload exists since C++17, sometimes referred to as hypot3.) Why do the C
and C++ standard libraries provide a function that is as simple as sqrt(a*a +
b*b)? It doesn’t save enough characters to warrant its existence, right? Have
you ever considered what happens if the input values are “very” small or large?
Or if an input is an IEEE754 special value such as infinity or NaN? Have you
ever considered how precise the calculation is, especially if an exact answer
is obvious if one of the inputs is 0?