C++ Monadic Interface

1 Overview 1.1 Monadic Interface In functional programming languages, the Monadic interface is a fundamental concept or mechanism for abstracting computational logic, expressing side effects, and controlling flow. This is because functions cannot produce side effects, such as IO, state modification, or throwing exceptions. However, in certain cases, such as reading and writing files, error … Read more

A New Era of Type Safety in C++: In-Depth Analysis of std::optional, std::variant, std::expected, and Herbception

A New Era of Type Safety in C++: In-Depth Analysis of std::optional, std::variant, std::expected, and Herbception

🔍Introduction: The Evolution from Wild Pointers to Type Safety C++17/23 introduced std::optional, std::variant, std::expected, and Herb Sutter‘s Herbception, which form the three pillars of modern C++ type safety. This article provides a comprehensive analysis of their differences and practical scenarios through illustrations+code, helping you write more robust code! 🛡️ 1. std::optional: An Elegant Expression of … Read more

After 10 Years of C++, I Discovered These Hidden Gems in STL

After 10 Years of C++, I Discovered These Hidden Gems in STL

Learning website for technical articles:https://www.chengxuchu.com Hello everyone, I am a chef, a programmer who loves cooking and has obtained a chef qualification certificate. STL accompanies C++ programmers in their daily development, but the most commonly used containers are often <span>vector</span>, <span>map</span>, <span>set</span>, and some of the most common algorithms. Many times, we only stay at … Read more

std::optional: A Joyful Little Box for Engineers in C++17

std::optional: A Joyful Little Box for Engineers in C++17

When writing C++ projects, do you often encounter scenarios like this: you write a function that may return a value or may not find a result, so you return <span>-1</span>, <span>nullptr</span>, or simply use a boolean value with an output parameter. These “workarounds” can be used, but they always feel a bit awkward. C++17 brings … Read more

Overview of New Features in C++14 and C++17

Overview of New Features in C++14 and C++17

Overview of New Features in C++14 and C++17 With the continuous development of programming languages, C++ is also undergoing constant updates and iterations. C++14 and C++17 are two significant versions that introduce many new features and functionalities, enhancing programming efficiency and readability. This article will detail some important new features in these two versions and … Read more