Brief bookclub talk I gave at work introducing the singleton design pattern in C++.Chapter 15 from Hands-On Design Patterns with C++ by Fedor G. Pikus. Source code:singleton.hpp | singleton.cpp
C++ Discord Server
San Diego C++ Meetup has a Discord server open to the public.If you’re passionate about C++ and want to meet likeminded people join us: https://discord.gg/rqQTzSxy
36th San Diego C++ Meetup
As always good times at the SDCPPM (also on Twitter)! Learned something new last night and met great people! Thanks again for organizing this Kobi! For those new to this Meetup: we meet once a month for few hours to discuss C++ features, techniques, questions asked no the net, and more. Sometimes we have guest […]
32nd San Diego C++ Meetup
Agenda: 1. Welcome slides – goals we would like to achieve in San Diego C++ Meetup2. C++ quiz3. Do you know what your std::remove(_if) does?4. Stackoverflow questions and discussions4a. How does the C++ compiler evaluate recursive constexpr functions so quickly?4b. How to check if int32_t number can fit in int8_t and int16_t?5. Quora question discussion […]
Use case of utilizing std::set instead of std::map
Some time back I reviewed code that had the following design and data structure: Now, the above is a struct but just imagine it could be a class with private/public sections, a beefy interface and data members. The author(s) of the code wanted to place it in some data structure that can help retrieve an […]
= delete; // not just for special member functions
During the 29th San Diego C++ Meetup fellow C++ enthusiast and contributor to my blog, Kobi, brought up something interesting about deleted functions and I wanted to share this little gem with you… To my surprise the = delete; postfix can be applied not only to special member functions like constructors or assignment operators, but to […]
C++20 Concepts
C++20 introduced the Concepts library and the corresponding language extensions to template metaprogramming. This post will be a brief introduction to the topic for people already well versed in C++ templates. What is a concept? Besides being a new keyword in C++20 it is a mechanism to describe constraints or requirements of typename T; it is […]
C++ Lambda Story, a book review
Everything you need to know about Lambda Expressions in Modern C++!
How to synchronize data access, part 2
Yesterday I wrote about How to synchronize data access, you should read it before continuing with this post, it will explain in detail the technique I will expand upon here. I’ll wait… Alright! Now that you understand how a temporary RAII object can lock a mutex associated with an instance of an object, effectively synchronizing […]
How to synchronize data access
I came across a post titled C++ Locking Wrapper shared by Meeting C++ on Twitter and it reminded me of Synchronized Data Structures and boost::synchronized_value so I decided to implement my own version as a learning exercise and possible topic of a future video on my YT channel. The idea is simple: synchronize across multiple […]
Templates, Linking and everything in between
Last weekend, San Diego C++ Meetup hosted Andreas Fertig. Andreas presented his excellent talk on “C++ Templates”. During his talk, one of the attendees asked a question that many, if not all, C++ programmers had asked at least once in their early life as C++ programmers. In this post, I hope it would provide answers […]
How to implement a memory pool
Last week I explained what a memory pool is and how to use it. This week my lesson was about implementing a simple memory pool capable of fixed size memory chunk allocations. The pool preallocates a block of memory on demand, carves out equal sized chunks from it, and returns a raw pointer each time […]
How to use memory pools
In this week’s class I explained what memory pools are and how to use them to optimize frequent allocations and deallocations of objects. I also demonstrated how to overwrite operator new / operator new [] and operator delete / operator delete [] for a struct / class type.The code for this class contains a simple benchmark which measures pool’s performance against […]
How to detect memory leaks
During my last week’s class I discussed a source-code method of finding memory leaks in C++. What do I mean by that? Source-code method is not a way of debugging a process like one could do with Valgrind on Linux or Deleaker on Windows (which I’ve used recently and really enjoyed its integration with Visual […]
26th San Diego C++ Meetup
The 26th Meetup of the San Diego C++ Group was held on May 18th, 2021 and featured guest speaker Arno Schödl, Founder & CTO of think-cell who spoke about A Practical Approach to Error Handling.
25th San Diego C++ Meetup
The 25th Meetup of the San Diego C++ Group was held on April 27th, 2021 and featured guest speaker Jerry Wiltse from the Conan Package Manager Team. The recording and slides of the presentation can be found here.
How to implement a spinlock / event / semaphore
Multi-threading has been the theme of my previous two classes where I discussed thread-pools and producer-consumer queues. Let’s talk about the fundamental aspects of multi-threading and some of its most basic building blocks: spinlocks, automatic and manual events, and semaphores.In this week’s class I will show you how to implement these building blocks using only […]
How to implement a producer-consumer queue
During my most recent class I discussed implementations of simple, multi-threaded, producer-consumer queues: unbounded (can grow in size indefinitely) and bounded (can only grow to a certain size). In short: the unbounded queue will block consumers’ pop() calls if it happens to be empty until a producer pushes something onto it. Bounded queue will do […]
How to implement a thread pool
By popular demand, and at the request of my coworkers, this week’s class was about implementing a simple thread pool using only standard C++ components. It would have taken 1h-30m if I didn’t completely forget how to use a condition variable. It’s 2h long!Bad std::condition_variable.wait(...) predicate caused a deadlock and I spent 30 minutes trying […]
Light-weight RPC framework
During my latest mentoring session with coworkers I was asked to explain how modern RPC frameworks work under the hood. What better way to illustrate this than to build one from scratch using components I blogged about previously (event objects, serializer framework, and TCP sockets). Although not part of the video recording (which I will […]