C++ Glossary

This page contains a list of terms specific to C++ community. I do not aim at this to be complete. There are certain terms used in C++ community that I have never seen comprehensively defined. This page collects them.

Small Buffer Optimization

An optimization technique often used for types implemented as a small handle to a bigger heap-allocated implementation (e.g. std::string). If the “implementation” part happens to be smaller than the size of the handle, rather than using heap allocation, it can be put in the place of (instead of) the handle. For a more detailed example see here.

Tagged Constructors

Constructors that accept an additional tag argument, with no value, but whose type is used to make the signature different from other constructors taking identical (or similar) set of non-tag arguments. Example:

std::mutex m;

std::unique_lock<std::mutex> l1 {m};
std::unique_lock<std::mutex> l2 {m, std::defer_lock};
std::unique_lock<std::mutex> l3 {m, std::try_to_lock};
std::unique_lock<std::mutex> l4 {m, std::adopt_lock};

In all four cases the non-tag argument is the mutex m, whereas defer_lock, try_to_lock and adopt_lock are tags. The three last constructors selected are tagged constructors. For more see here.

Type Erasure

A technique of programming where all family of types are converted into one type (with common interface), so that one function can handle all of the different types without having to know them. For more see here.

Value Semantics

A way of writing programs, where programmers focus on values carried by objects rather than objects and their identities. This is somewhere in between imperative programming and functional programming; very useful in multi-threading as it avoids data races. For more see here.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s