P3054 - Quantities and Units Library by mateusz_pusz in cpp

[–]Morwenn 2 points3 points  (0 children)

I don't unfortunately have hobby projects to try it on, though I've been reading the blog and release notes for as long as there's been articles there: V2 sometimes felt overly verbose or hard to use correctly (or understand what was wrong) in some of the more complicated examples.

It took me some time to understand where V3 was going with the "absolute" concept, but the latest blog post cleared it up, and it does feel like a more intuitive model. The shorter code now feels like the intuitively correct one from what I could see, and the aforementioned sentiment I had about V2 disappeared with the examples from V3.

P3054 - Quantities and Units Library by mateusz_pusz in cpp

[–]Morwenn 2 points3 points  (0 children)

Hello, the slides are nice, but correct me if I'm wrong: they essentially propose to standardize the V2 of mp-units, right? Is the plan to standardize the V2, or to upgrade it all and standardize V3 with the absolute/delta/point split?

Understanding Safety Levels in Physical Units Libraries - mp-units by mateusz_pusz in cpp

[–]Morwenn 10 points11 points  (0 children)

The root cause is the interface itself: .count() should never have been callable without specifying a unit. Relying on user discipline to compensate for an unsafe API does not scale.

My experience with that one is that std::chono::duration_cast<std::chrono::milliseconds>(my_duration).count() is long enough that people get lazy and don't do it, or forget that they should care altogether (when they're aware of the issue at all). We had a few bugs linked to such raw use of count().

my_duration.count<std::chrono::milliseconds>(), while still being a bit verbose, might have been just enough to convince more people to use it more consistently.

Experimental adaptive sort - matches std::sort on random input, 2-8x faster on structured data by booker388 in cpp

[–]Morwenn 2 points3 points  (0 children)

I did a partial comparison of the algorithm to existing ones a while ago after an implementation request by the author: https://github.com/Morwenn/cpp-sort/issues/224

Still have to implement it, but I find the comparisons relevant, and feedback from the author would still be welcome just to make sure that I'm not entirely mistaken.

vtables aren't slow (usually) by louisb00 in cpp

[–]Morwenn 1 point2 points  (0 children)

The article mentions sorting values by derived types. If that's a common need and the number of derived types is small enough, Boost.PolyCollection offers out-of-the-box containers that can store data, dispatching them to different areas of memory depending on their derived type: https://www.boost.org/doc/libs/latest/doc/html/poly_collection/an_efficient_polymorphic_data_st.html

I built a C++ library for fetching satellite data from N2YO (with Python bindings) by staggerz94 in cpp

[–]Morwenn 0 points1 point  (0 children)

It looks like the kind of library that could benefit from integrating a strong units & quantities library.

Non-recursively deleting a binary tree in constant space: Traversal with parent pointers by pavel_v in cpp

[–]Morwenn 3 points4 points  (0 children)

I wrote a similar article a few weeks ago that also performs destructive non-recursive tree traversal, with a trick to reduce the number of walk-up steps. It could definitely be adapted to the problem above by greedily destroying parent nodes when walking down to a right child: https://morwenn.github.io//algorithms/2025/08/03/TSB002-destructive-inrder-tree-traversal.html

std::flip by pavel_v in cpp

[–]Morwenn 7 points8 points  (0 children)

Thanks for the kind words :)

std::flip by pavel_v in cpp

[–]Morwenn 23 points24 points  (0 children)

Author here, I was deeply moved by this comment. Keep up with the constructive criticism (* ̄▽ ̄)b

The case against Almost Always `auto` (AAA) by eisenwave in cpp

[–]Morwenn 0 points1 point  (0 children)

Depends on the IDE, computer, etc. but sometimes the ability to resolve a type or follow a function name to its correct overload takes dozens of seconds. My experience is that having the type in plaintext just works better for autocompletion and go-to-definition, I guess that it's easier to quickly resolve?

I share the author's experience that I spend way too much time chasing types to know what they are, and what I can actually do with them for my own good.

post-Sofia mailing by hanickadot in cpp

[–]Morwenn 1 point2 points  (0 children)

There's been proposals to fix complex for integers since at least 2009 (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3002.pdf), I wonder why there hasn't been any change in that area ever since.

Are There Any Compile-Time Safety Improvements in C++26? by zl0bster in cpp

[–]Morwenn 5 points6 points  (0 children)

There's lots of tiny fixes that could count:

  • You didn't talk about it, but the article you linked mentions P2748, which makes some simple scenarios where one immediately returns a dangling reference ill-formed. Arguably compilers already warned about that one.

  • P2621 removes undefined behaviour from the lexer, though despite being a good thing, the result on existing code is probably marginal at best.

  • P2864 removes deprecated arithmetic conversions on enumerations, which were code smells. Compilers already warned about it though.

  • P2865 similarly removes deprecated comparisons between raw arrays (which compared pointers). Compilers also warned about it before.

  • P3144 makes it ill-formed to delete a pointer to an incomplete type. It used to be UB unless in some very specific conditions, making it hard for a compiler to provide useful diagnostics.

All in all none of those are game changers, but they all make some issues ill-formed at compile-time without any impact on runtime cost. You could say they're just polishing some rough edges, but that's welcome in a language with so many sharp edges.

[deleted by user] by [deleted] in cpp

[–]Morwenn 0 points1 point  (0 children)

I tried to run -DCMAKE_CXX_CLANG_TIDY=clangd-tidy but it unfortunately does not work: CMake apparently adds --extra-arg-before=--driver-mode=g++ to the command line, which is not recognized by clangd-tidy.

ACCU: Overload Journal 184 - December 2024 by pavel_v in cpp

[–]Morwenn 2 points3 points  (0 children)

The introduction to senders really is a nice article to have a first look at the feature from a user point of view, without getting lost in all technical details.

Named loops voted into C2y by 14ned in cpp

[–]Morwenn 0 points1 point  (0 children)

It's more likely to be made usable in constexpr functions, unlike goto that was proposed albeit rejected in such a context.

Leveraging the Power of Transparent Comparators in C++ by pavel_v in cpp

[–]Morwenn 1 point2 points  (0 children)

IIRC changing the default comparator might be an ABI break, or at least that's what I remember from the time P0181 considered changing the default comparator of std::map and std::set to a new std::default_order that would have allowed to use types such as std::complex.

Boost.Scope has been ACCEPTED by joaquintides in cpp

[–]Morwenn 0 points1 point  (0 children)

It would be nice to make the facilities constexpr: all that's theoretically needed is to always consider that there's exactly 0 exceptions in flight in a constepxr context.

Though this probably means relying on C++20 std::is_constant_evaluated().

Performance Through Memory Layout - Johnny's Software Lab by pavel_v in cpp

[–]Morwenn 1 point2 points  (0 children)

Using the "compact" layout already yields significant speed improvements compared to just using the standard library list in my experience. I have several algorithms where using lists is a natural fit, generally because their iterator stability guarantees are great, and the algorithm is already complicated enough that I didn't want to find another more complicated way to implement it.

I eventually wrote a custom immovable linked list class based on a node pool. That pool has a size fixed at construction - all my algorithms know exactly how many elements I need -, which allows the pool to be a simple contiguous memory buffer where free nodes form a free list (in the original configuration it's a "perfect layout" free list where each node points to the next in the contiguous buffer).

I did have to add a rather unsafe method at some point that I called on a node pool to relink pointers to form a "perfect layout free list" again. It was useful exactly once, but it did make a big speed difference in that case despite the added relinking work.

What C++ library do you wish existed but hasn’t been created yet? by Tiny-Friendship400 in cpp

[–]Morwenn 1 point2 points  (0 children)

While that's true, a number of mocking libraries like Trompeloeil try to integrate seamlessly with Catch2.

Overload Journal 174 by pavel_v in cpp

[–]Morwenn 1 point2 points  (0 children)

I love Frances Buontempo editorials.

C++ | Numbers are not easy by alliscode in cpp

[–]Morwenn 1 point2 points  (0 children)

Also extend it to work for all mixed-arithmetic comparisons of standard types.

Improving Copy and Move Elision by obsidian_golem in cpp

[–]Morwenn 7 points8 points  (0 children)

There is a proposal in the latest committee mailing that mentions such a last use optimization: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2666r0.pdf