RECENT ARTICLES

std::jthread and cooperative cancellation with stop token

Tutorial | Dec 12, 2020 | hkumar 

C++20’s std::jthread is an exception-safe alternative of std::thread that politely stops and joins the thread automatically in the destructor.

Read 

std::variant as a map key and std::hash

Tutorial | Dec 4, 2020 | nwheeler 

How std::variant can be used as a map key and why it can be useful.

Read 

std::any - comparison with void* and motivating examples

Tutorial | Nov 23, 2020 | hkumar 

std::any is a vocabulary type that characterizes a type-discriminating container of any single value. It can replace the unsafe void* patterns in many situations.

Read 

std::list splice for implementing LRU cache

Tutorial | Nov 28, 2020 | hkumar 

std::list splice can transfer a node to a different position within the same list without copying or moving the element. We use this feature to implement a Least Recently Used (LRU) cache.

Read 

Update keys of map or set with node extract

Question | Oct 8, 2020 | hkumar 

C++17 standard introduced the node extraction, making it possible to unlink an associative container's node, update its contents, and reinsert it in the same or another compatible container.

Read 

unique_ptr, shared_ptr, weak_ptr, or reference_wrapper for class relationships

Tutorial | Jul 5, 2020 | nextptr 

Modern-C++ constructs — unique_ptr, shared_ptr, weak_ptr, and reference_wrapper — express relationships among classes more intelligibly than raw pointers.

Read 

Move std::unique_lock to transfer lock ownership

Question | Jul 13, 2020 | hkumar 

A unique_lock can be moved to transfer the lock ownership.

Read 

EXPLORE SERIES
C++ : Know More

"C++: Know More" is a series of C++ question blogs ranging from basic to advance level. Whether you are a student learning C++, or a professional who wants to hone their skill, you would always find something useful here.


C++11 - An Even Better C++

This series is about the C++11 standard of C++. We cover C++11 topics such as lambda expressions, rvalue references and move constructors, automatic type inference - auto, nullptr, strongly typed enums, unrestricted unions, variadic templates, smart pointers, explicit overrides of virtual functions, defaulted and deleted special member functions, initializer lists, and more.


C++ interview questions on pointers and references

This C++ series has commonly asked beginner to expert level questions on pointers and references.


Reveries of Java data types

Java, like C++ and C#, is a statically typed language. Statically typed languages have various data types (e.g. int, float, and boolean) to support strict type checking at compile time, called type safety. Java has 8 primitive data types namely byte, short, int, long, float, double, boolean, and char. In addition to 8 primitive types the language has built-in support for character strings though type String. In this series we talk about the primitive types, String and operations on those. We are also going to have some questions on arrays of these types.


Operator Overloading In C++

Operator overloading in C++ is one of the key features at the core of the programing language. It enables programmers to add same syntactic support to user-defined types as of primitive types. This series has questions on common operator overloading concepts and patterns like functor, smart-pointer, deep-copy, move semantics, user-defined types as keys in associative containers, and more.