RECENT ARTICLES

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 

Array of reference_wrapper: an alternate array of references

Question | Jun 28, 2020 | hkumar 

An array of references is illegal, but it is possible to create an array of std::reference_wrapper.

Read 

std::ref and std::reference_wrapper: common use cases

Tutorial | Jun 25, 2020 | hkumar 

std::reference_wrapper<T> is a copyable and assignable object that imitates a reference (T&). It gives the non-nullable guarantee of a reference and the pointer-like flexibility to rebind to another object.

Read 

Capture *this in lambda expression: Timeline of change

Tutorial | Jun 12, 2020 | hkumar 

How the current object (*this) can be captured in a lambda expression has gone through some changes since C++11.

Read 

Type-safe integer types with list initialization of scoped enums

Tutorial | Jun 7, 2020 | hkumar 

List-initialization of scoped enums (aka enum class) since C++17 makes it possible to roll out new distinct type-safe integer types.

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.