Skip to content

Instantly share code, notes, and snippets.

View louis-langholtz's full-sized avatar

Louis Langholtz louis-langholtz

View GitHub Profile
@louis-langholtz
louis-langholtz / cpp-thread-safe-initialization.md
Last active November 26, 2023 06:11
C++ Requires Thread Safe Initialization of Block-Scope Variables With Static or Thread Storage Duration

C++: Thread Safe Initialization Requirements

Seems like this has come up for me enough in discussing C++ with others, that it might help to put together the information in this gist.

Standard C++ has since C++11 required that block-scope variables with static or thread storage duration get initialized in a thread safe way. Besides there being a StackOverflow answer - to a related question - showing some example assembly for C++11 that includes thread safe guards, there's also the C++ standard documents themselves.

What follows is the specific requirement by versions of the standard.

C++03

@louis-langholtz
louis-langholtz / CppNoStdEndl.md
Last active October 24, 2023 02:40
C++: More Reasons To Avoid std::endl

C++: More Reasons To Avoid std::endl

In the realm of death by a thousand cuts, please stop using std::endl and remove it from code. Per cppreference.com, std::endl "inserts a newline character into the output sequence... and flushes it". Okay, so why exactly shouldn't it be used???

The Issues

There have been numerous articles written about endl that echo the sentiment against using it. Here's some:

@jamieweavis
jamieweavis / macos-app-icon.md
Last active June 16, 2024 22:18
How to create an .icns macOS app icon
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 29, 2024 03:40
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k