A lambda function is a function that you can write inline in your source code In this article, I’ll first explain why lambdas are great, what are closures vs how lambdas are different from closures? — with some examples — and then I’ll walk through all of the details of…

Using In-member initialization, using constructors smartly and using class members functions in a safe and proper way to avoid mistakes

Clean code!

Table of Contents

  1. Use member initializers in the same order as their declaration
  2. Prefer in-class member initializer over constant initializations OR over default constructor.
  3. Don’t cast away const, ever!
  4. Use delegating constructors to…

Some puzzles from various talks, blog posts, and other bits

Table of Contents

  1. Puzzle 1: Capturing unique_ptr by reference
  2. Puzzle 2: Capturing the temporary by the reference
  3. Puzzle 3: Making mistakes with std functions usage
  4. Puzzle 4: Throwing away the dead

Puzzle 1: Capturing unique_ptr by reference

unique_ptr<A> myFun()
unique_ptr<A> pa(new A());

Let’s discuss what coroutines are in general and how C++20 is introducing them

Table of Contents

1. Prerequisite Terminology
2. What are coroutines?
3. Coroutines vs Subroutines?
4. Coroutines vs Threads
5. Applications of coroutines
6. Example in Python
7. How to simulate coroutines in traditional C++
8. Coroutines in C++20
9. Restrictions

Prerequisite Terminology

How to use a custom deleter with an unique_ptr and shared_ptr

Related post: https://medium.com/pranayaggarwal25/a-tale-of-two-allocations-f61aa0bf71fc

Table of Contents

  1. Introduction
  2. The true unknown face of smart pointers
  3. What is std::default_delete indeed?
  4. Ways to specify custom deleters
  5. Using custom deleter with shared_ptr
  6. Using custom deleter with unique_ptr
  7. Storage of custom deleters
  8. Restrictions that come with custom…

Pranay Kumar

Computer Scientist @ Adobe Systems https://pranayaggarwal.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store