In this blog post, we’ll look at static variables defined in a function scope. We’ll see how they are implemented and how to use them. What’s more, we’ll discuss several cases where we can avoid extra thread-safety cost. Let’s start. Introduction As you may know, C++ offers a way to define static variables in a function/block scope: