News for hackers. Stuff that matters.
Re:C++26: A Placeholder with No Name by MathMonkeyMan on Saturday January 11, 2025 @11:29AM (#42666924)
I write my code with the assumption that the reader does _not_ have access to a "smart" IDE.

I use `auto` when the type is obvious or doesn't really matter, and I seldom create aliases for types.

I feel like having verbose type names at function boundaries and using `auto` for dependent types is the sweet spot. I'll often avoid `auto` when referring to a class data member, so the reader doesn't have to refer to the definition.

    void foo(const std::multimap<double, Order>& sells) {
        for (const auto& [price, order] : sells) {
            // ...
        }
    }
but also

    void foo(const OrderBook& book) {
        const std::multimap<double, Order>& sells = book.sells;
        for (const auto& [price, order] : sells) {
            // ...
        }
    }
`auto` is convenient for iterators. Which of the following is better?

    auto iter = sells.begin();
    std::multimap<double, Order>::const_iterator iter = sells.begin();
Re:C++26: A Placeholder with No Name by Koshkin on Saturday January 11, 2025 @12:00PM (#42667167)
Off-topic, but just wanted to note that using floating-point numbers as keys may be generally a bad idea (unless you use a custom comparator that takes into account the error that can accumulate during calculations).
Re:C++26: A Placeholder with No Name by mgaunard on Saturday January 11, 2025 @12:30PM (#42667387)
especially for an order book...