Asio-grpc: A Comprehensive Guide to the Asynchronous gRPC Library Based on Asio/Executors

Asio-grpc: A Comprehensive Guide to the Asynchronous gRPC Library Based on Asio/Executors

Asio-grpc: A Comprehensive Guide to the Asynchronous gRPC Library Based on Asio/Executors 1. Project Overview Asio-grpc is a header-only library based on C++17 that provides robust asynchronous support for gRPC. It enables developers to write gRPC clients and servers using various modern C++ asynchronous programming paradigms by providing an Asio executor compatible with the grpc::CompletionQueue … Read more

How Does C++ Read-Write Lock (shared_mutex) Work?

How Does C++ Read-Write Lock (shared_mutex) Work?

Sometimes, we encounter a situation where: “many reads, very few writes.” For example, configuration, status information, coordinate parameters, etc. If all threads use <span>std::mutex</span>, then read operations will queue up, wasting performance, which is unfortunate πŸ˜… To solve this problem, C++17 introduced a smarter lock πŸ”’: “std::shared_mutex”. Why is it called a Read-Write Lock? You … Read more

Understanding the C++ ‘maybe_unused’ Specifier

Understanding the C++ 'maybe_unused' Specifier

For unused function parameters or unused local variables, the compiler will issue a corresponding warning. Generally, if you want to avoid seeing this warning, you can disable it using preprocessor directives, although the syntax for these directives varies slightly between different compilers and needs to be adapted. However, starting from C++17, a new attribute specifier … Read more

The Top Ten Features of C++17 for Business Code

Author: Jinshang, Backend Developer at Tencent WXG Since the advent of modern C++, the C++ language standard has established a convention of releasing a new version every three years: C++11 marked the beginning of modern C++, C++14 filled in the gaps of C++11 without adding many new features, and C++17, as the first major version … Read more

Installing GCC 12 on CentOS 7: A Comprehensive Guide from Dependency Preparation to Compilation Verification

Installing GCC 12 on CentOS 7: A Comprehensive Guide from Dependency Preparation to Compilation Verification As a “compilation tool” in Linux systems, GCC (GNU Compiler Collection) is a core tool for developing programs in C, C++, and more. However, the default GCC version that comes with CentOS 7 is relatively low (usually 4.8.5), which cannot … Read more

Analysis of libc++ STL Source Code – type_traits

In the previous section, we explained the concept of SFINAE. Although concepts were introduced in C++20, most of the experimental features in the standard library still utilize the SFINAE principle. Therefore, understanding this concept is key to comprehending the STL source code. Why start with type traits? Type traits are relatively simple, which can enhance … Read more

C++17 Language Features

Language Features if/switch Initialization Statements if (auto it = m.find(key); it != m.end()) { std::cout << "Found: " << it->second; } Inline Variables, Declaration Only in Header Files // In header file class MyClass { static inline int count = 0; // No need for additional definition in .cpp }; Fold Expressions template <typename… Args> … Read more

C++17 Features Used in plog

C++17 Features Used in plog plog is a relatively lightweight logging library primarily based on C11/14, which **does not heavily rely on C17**, but it does support and utilize some C++17 features. 1. Inline Variables The inline variable feature introduced in C++17 allows the definition of global variables in header files without violating the ODR … Read more

svector: An Optimized Compact SVO Vector for C++17 and Above

svector: An Optimized Compact SVO Vector for C++17 and Above In modern C++ development, performance and memory efficiency are key considerations for building efficient applications. std::vector, as the most commonly used dynamic array container in the standard library, offers flexible memory management and powerful features, but its Small Object Optimization (SOO) strategy is relatively limited. … Read more

Advanced Guide to the C++ auto Keyword: Insights and Pitfalls from C++11 to C++17

Advanced Guide to the C++ auto Keyword: Insights and Pitfalls from C++11 to C++17 In the modern evolution of C++, the <span>auto</span> keyword is undoubtedly a revolutionary feature. It has transformed from a “chicken rib” in the C++98 era to a “power tool” in C++11 and later versions, greatly enhancing the simplicity and maintainability of … Read more