Daily bit(e) of C++

Daily bit(e) of C++ is a Substack focused on C++ programming, offering insights into modern C++ practices, standard library improvements, language features introduced in recent standards, and common programming patterns and problems. It covers both basic and advanced topics, aiming to enhance the understanding and application of C++ for its readers.

Modern C++ Features C++ Standard Library Programming Patterns Software Development Tools Language-Specific Patterns and Practices Code Optimization and Efficiency Error Handling Memory Management C++ Standard Improvements Integration with C APIs

The hottest Substack posts of Daily bit(e) of C++

And their main takeaways
78 implied HN points 13 Jul 23
  1. std::sort is a well-known sorting algorithm in C++.
  2. It sorts elements by default in non-descending order.
  3. C++17 and C++20 standards introduced improvements, like a parallel variant and range version.
98 implied HN points 22 Feb 23
  1. Heap algorithms like std::make_heap, std::pop_heap, std::push_heap, std::sort_heap can replace std::priority_queue and std::set for continuous storage and efficient element extraction.
  2. Benefit of using heap algorithms is keeping elements in continuous storage but with a more error-prone interface.
  3. Subscribing to Daily bit(e) of C++ can provide insights on C++ programming topics.
Get a weekly roundup of the best Substack posts, by hacker news affinity:
78 implied HN points 27 Feb 23
  1. Use std::shuffle in C++ to shuffle elements into a random order.
  2. The algorithm relies on a random engine as the source of randomness.
  3. For basic operations, the default_random_engine in C++ is usually adequate to use.
78 implied HN points 23 Feb 23
  1. C++20 introduced std::span, a view for wrapping contiguous memory blocks.
  2. std::span can bridge C and C++ code by accessing the byte representation.
  3. When dealing with legacy code or C APIs, errors can occur when passing data as C arrays.
78 implied HN points 21 Feb 23
  1. The post discusses the common C++ interview problem of serializing and de-serializing an n-ary tree.
  2. Format choice is important, each node in the tree has a uint32_t value and a vector of weak pointers to children.
  3. Serialization is achieved with a recursive pre-order traversal and terminal value format, deserialization involves reading input until a negative value.
78 implied HN points 24 Apr 23
  1. C++17 introduced the [[nodiscard]] attribute to trigger a compiler warning when a function call result is discarded.
  2. Use the [[nodiscard]] attribute for expensive functions and query functions that may be confused with action counterparts.
  3. The Compiler Explorer tool can be used to explore code examples related to the [[nodiscard]] attribute.