Re-entrant vs. Thread-safe

These two are very different concepts but can be confusing. re-entrant is used to describe a function in a single-threaded environment, thread-safe in multi-threaded environment on the other hand. A function can be both re-entrant and thread-safe, either re-entrant or thread-safe, or neither. A function is re-entrant, if it can…

Proper Boost Installation on OSX

boost is THE C++ library out there. Many features were introduced in boost before adopted in C++ standard. I want to have it installed on my local Mac laptop, so I can easily play with it. homebrew formula not working brew install boost is the first thing I did and…

A Look into Return Value Optimization of C++

I am learning C++ and ran into a "bizarre" issue, which was because Return Value Optimization (RVO) took place. In the spirit of learning C++, let's take a look into what's happening here. This is the code we will be looking at. struct Foo { Foo() { cout << "foo constructed" << endl; } Foo(…