Anders Schau Knatten's Avatar

Anders Schau Knatten

@knatten.bsky.social

I like C++, industrial music, and figuring out how computers work. Author of C++ Brain Teasers, http://blog.knatten.org, https://cppquiz.org and https://moduloone.com.

477 Followers  |  190 Following  |  98 Posts  |  Joined: 10.08.2023  |  2.0099

Latest posts by knatten.bsky.social on Bluesky

We just published a new question! This one was contributed by GitHub user demercurizer. https://cppquiz.org/quiz/question/394

13.10.2025 07:50 β€” πŸ‘ 1    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0
Me pointing at slides in front of the crowd

Me pointing at slides in front of the crowd

A quiz question on a screen in front of the audience

A quiz question on a screen in front of the audience

The reMarkable team celebrating their victory

The reMarkable team celebrating their victory

An overview of the audience

An overview of the audience

Some pictures from my C++ Quiz at @ndcconferences.com TechTown. Thanks to everyone who came, and congratulations to the reMarkable team who won with a very impressive score!

10.10.2025 08:44 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

We just published a new user contributed question! https://cppquiz.org/quiz/question/393

06.10.2025 07:40 β€” πŸ‘ 2    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0

We just published a new question! This one was contributed by Armen Aslanyan: https://cppquiz.org/quiz/question/391

29.09.2025 07:20 β€” πŸ‘ 1    πŸ” 2    πŸ’¬ 0    πŸ“Œ 0
C++ Under the Sea 2025 – International C++ Conference 2025

My proposal to C++ Under The Sea was accepted, so I'll be visiting for the first time! I'll be talking about the two memory models (language and CPU). Looking forward to it! cppunderthesea.nl

28.09.2025 07:26 β€” πŸ‘ 8    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Conan.io - the Open Source C and C++ Package Manager for Developers Conan is an open source, decentralized and multi-platform package manager for C and C++ that allows you to create and share all your native binaries.

Update, that worked! Ffmpeg 4.6 is now available: conan.io/center/recip...

28.09.2025 07:24 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

You too!

21.09.2025 18:32 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Intentionally obscured tiny C++ program

Intentionally obscured tiny C++ program

On the πŸš„ to @ndcconferences.com TechTown, eating candy and chuckling to myself at this question for the Wednesday evening C++ pub quiz. What's the question? You'll have to wait and see...

21.09.2025 17:50 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Cover of the book C++ Brain Teasers by Anders Schau Knatten

Cover of the book C++ Brain Teasers by Anders Schau Knatten

Get my book at 40% off!

There's a flash sale at @pragprog.com right now, and you can get all their books at 40% off with the promo code "flashsale".

pragprog.com/titles/akbra...

18.09.2025 12:06 β€” πŸ‘ 4    πŸ” 2    πŸ’¬ 0    πŸ“Œ 0
Post image

Happy to announce another Pre-NDC-TechTown Oslo C++ Users Group Meetup! This year we'll have a talk by Klaus Iglberger, and as usual, @ndcconferences.com is sponsoring pizza. www.meetup.com/ocppug/event...

13.09.2025 06:40 β€” πŸ‘ 1    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0

I've never made a PR to ConanCenter before. There was a fix in ffmpeg 4.4.5 which I need in order for ffmpeg 4.* to compile with GCC >12. ConanCenter currently support ffmpeg 7.1.1 and 4.4.4. Is it likely that they'll accept a PR which adds 4.4.6?

08.09.2025 12:55 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
clang-tidy - modernize-use-scoped-lock β€” Extra Clang Tools 22.0.0git documentation

Just read the docs and discovered that you can turn off WarnOnSingleLocks. That helps, but should be the default imo. clang.llvm.org/extra/clang-...

01.09.2025 10:49 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
C++ static code analysis | since-c++17 Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your C++ code

Sonar has the same check as clang-tidy: rules.sonarsource.com/cpp/tag/sinc...

01.09.2025 10:29 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Preview
Compiler Explorer - C++ (x86-64 clang (trunk)) int main() { std::mutex m; { // Normal use case std::lock_guard l{m}; } { // Fails to compile if you forget to pass it the mutex, good! std::lock_guard ...

Clang-tidy 21 wants you to prefer scoped_lock over lock_guard. I feel scoped_lock should be a specialized tool when you need to lock several mutexes. It also allows you to pass it zero mutexes, which for a bug lock_guard doesn't allow: godbolt.org/z/WzG4YeP83

Do you think clang-tidy is right?

01.09.2025 07:24 β€” πŸ‘ 4    πŸ” 2    πŸ’¬ 2    πŸ“Œ 0
Preview
Discord - Group Chat That’s All Fun & Games Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.

For reference, here's the thread discordapp.com/channels/400...

12.08.2025 07:55 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

So intuitively, I'd expect that example to be just fine. I would just like to have a good source for that assumption. But then sehe, who counts as "asio documentation" in my book, seems to tell me I have to use an atomic here.

12.08.2025 07:49 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Found the thread on Discord, thanks! My question is what "proper synchronization" means. I agree that it has to do some sort of synchronization, but it also has to be fast and not do *too much* synchronization. Your example of "auto foo = new std::string();" is exactly what I'm trying to understand.

12.08.2025 07:42 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Haha, wrong asio! But thanks for wanting to help!

08.08.2025 10:28 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Preview
Do asio initiating functions synchronize with the completion handlers? I'm trying to understand the memory order related to asio initiating functions and completion handlers, but I can't find any documentation on this. Asio examples tend to start the io_context::run t...

Can someone help me with an Asio question? Does an initiating function synchronize (memory model-wise) with the corresponding completion handler? stackoverflow.com/questions/79...

08.08.2025 09:27 β€” πŸ‘ 2    πŸ” 2    πŸ’¬ 2    πŸ“Œ 0
Preview
Anders Schau Knatten - The Two Memory Models Programming languages like C, C++, and Rust all define a memory model, which allows you to reason about the ordering of memory operations in your program

I'll be back at the @meetingcpp.bsky.social in Berlin this year to speak about the two memory models! Really happy about this since it's only my second time there and I didn't make the cut last year. Looking forward to it! meetingcpp.com/mcpp/schedul...

26.06.2025 19:07 β€” πŸ‘ 6    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0
Video thumbnail

Buy my C++ book! Or get three chapters for free at pragprog.com/titles/akbra... (no registration required)

18.06.2025 16:34 β€” πŸ‘ 3    πŸ” 5    πŸ’¬ 0    πŸ“Œ 0
The Two Memory Models - Anders Schau Knatten - NDC TechTown 2024
YouTube video by NDC Conferences The Two Memory Models - Anders Schau Knatten - NDC TechTown 2024

Unfortunately we did not record it. But you can see a slightly shorter version of the same talk at youtu.be/rZaPQkpuEeM?...

17.06.2025 05:36 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
First slide of my presentation The Two Memory Models

First slide of my presentation The Two Memory Models

Meetup with Oslo C++ Users Group in one hour!

16.06.2025 13:57 β€” πŸ‘ 4    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

(That's just a random link I found btw, not an endorsement of the website)

13.06.2025 14:39 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Preview
Kontorsstol HΓ₯g SoFi svart komfort klΓ€dsel Unik kontorsstol som passar fΓΆr mΓ₯nga

I'm super happy with my HΓ₯g Sofi www.lomax.se/mobler/stola...

13.06.2025 14:38 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
NOR 3 - 0 ITA

NOR 3 - 0 ITA

🀯

06.06.2025 21:02 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

We're finally back up, after almost a week of absolutely horrible customer support from @dreamhost.bsky.social. Eventually, after trying to avoid helping, ignoring me, not accepting responsibility, and blaming everything else, they found and fixed the configuration issue on their server.

01.06.2025 08:29 β€” πŸ‘ 1    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0

I'm still working with @dreamhost.bsky.social support on this. All my websites on this server have been unstable since the upgrade they made on Tuesday, and we've still not gotten to the bottom of it.

31.05.2025 08:05 β€” πŸ‘ 0    πŸ” 1    πŸ’¬ 0    πŸ“Œ 1

Heads up, we will have ~30 minutes of downtime on 27 May due to a server upgrade.

26.05.2025 19:37 β€” πŸ‘ 0    πŸ” 1    πŸ’¬ 0    πŸ“Œ 1

@knatten is following 18 prominent accounts