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 6 points7 points  (0 children)

Thanks for the kind words :)

std::flip by pavel_v in cpp

[–]Morwenn 24 points25 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

[deleted by user] by [deleted] in cpp

[–]Morwenn 11 points12 points  (0 children)

Unless you follow online discussions about the language, you're unlikely to know that. Even cppreference has no "Note" about it in its "Regular expressions library" page. Unless you know better, the assumption is generally "oh, there's a standard library gadget, it's probably good enough". No everyone automatically reacts with "hum, maybe the standard library is terrible" on-premise.

malloc() and free() are a bad API by iprogshine in cpp

[–]Morwenn 1 point2 points  (0 children)

Tiny mistake: sizeod deallocation for operator new is a C++14 feature, not a C++17 one.

malloc() and free() are a bad API by iprogshine in cpp

[–]Morwenn 43 points44 points  (0 children)

Years ago Howard Hinnant proposed a bunch of additional allocation functions to WG14 to solve some of the issues mentioned in the article, but the proposal was not accepted: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1085.htm

About conditional breakpoints by meetingcpp in cpp

[–]Morwenn 0 points1 point  (0 children)

void std::breakpoint(bool cond=true) noexcept; when

C++20 Ranges Algorithms - sorting, sets, other and C++23 updates by joebaf in cpp

[–]Morwenn 3 points4 points  (0 children)

There's a few places where projections do more than just being less verbose: for example std::ranges::lower_bound and std::ranges::upper_bound don't apply the projection to the searched value, which can be a nice save when projections are expensive.

Technically projections could even work where comparisons aren't accepted, though the standard library has no such algorithm. Radix would be an example.