Work in progress: 181,232 of 181,233 sites checked so far, more every week · updated 2 Nov 2026Missing a blog? Tell us

Top all-time · #9599

F

Filip Roséen

Personal blog · b.atch.se/postsprogramming

Filip Roséen writes refp.se, a personal blog at b.atch.se about programming. Since 2015, 8 different Hacker News readers have linked it 16 times, most often “How to implement a constant-expression counter in C++”. It is still writing: the last post was on 2026-08-05, and you can follow it by feed.

Visit the blog
16mentions?
8HN people?
2015–2025first – last linked?
Links on Hacker News per year · peak 8 in 2015

Too few sampled comments (7) to say how often HN recommends it.?

Why HN links it

HN readers link Filip Roséen's posts on C++ compile-time tricks, such as non-constant constant expressions and a compile-time counter, as examples of template and compiler quirks.

Summarised by Claude from a sample of 7 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.

Discover thought-provoking, funny, and insightful content by Filip Roséen — articles that make you say TIL, WTF, or LOL (sometimes all at once). A blend of programming, creativity, and humor for the curious mind.

Most-linked posts?

  1. How to implement a constant-expression counter in C++
    4 people · 4 mentions · first linked 2015-05-11
  2. Non-constant constant-expressions in C++
    3 people · 5 mentions · first linked 2015-04-26
  3. /posts/non-constant-constant-expressions/
    2 people · 2 mentions · first linked 2021-07-29

What Hacker News says?

  1. Yes, but hopefully without the amusing issue of non-constant constexpr functions in C++ :) http://b.atch.se/posts/non-constant-constant-expressions/

    Comment linking /posts/non-constant-constant-expressions/

    on “Announcing Rust 1.33.0”
  2. Submitted Non-constant constant-expressions in C++ as a story · 71 points

    HN discussion
  3. atq2119 · 2019-04-28Recommends
    Templates are not quite side-effect free, although it takes some effort to run into that. See http://b.atch.se/posts/constexpr-counter/ for a delicious exploit of that fact.

    Comment linking /posts/constexpr-counter/

    on “Stop Memsetting Structures”
  4. Submitted How to implement a constant-expression counter in C++ as a story · 46 points

    HN discussion
  5. You haven't lived until you've implemented a compile-time counter in C++: http://b.atch.se/posts/constexpr-counter/ (which doesn't rely on compiler bugs)

    Comment linking /posts/constexpr-counter/

    on “Living with Microsoft C++ Compiler Bugs and Ambiguities”
  6. Submitted How to implement a stateful meta-container in C++ as a story · 17 points

    HN discussion
  7. > template mechanism is 100% pure Let's say 99.99%. You underestimate the resourcefulness of C++ (meta-)programmers and their ability to leverage implementations or specification bugs for "useful" purposes: https://b.atch.se/posts/non-constant-constant-expressions/

    Comment linking /posts/non-constant-constant-expressions/

    on “Compiling C++ with the Clang API”
  8. Submitted How to implement a compile-time meta-container in C++ as a story · 2 points

    HN discussion
  9. It looks like nobody managed to beat this one from 2015 yet: http://b.atch.se/posts/non-constant-constant-expressions/ "Implementing f() to make the following snippet compile without the static_assert being fired looks impossible, doesn't it? // <insert solution here> int main () { constexpr int a = f(); constexpr int b = f(); static_assert (a != b, "fail"); } We all "know" that an expression that is usable in a con…

    Comment linking /posts/non-constant-constant-expressions/

    on “Esoteric C++ Contest 2018”
  10. I just submitted a request to join the reflector where I know this is being discussed; nonetheless, information will be published on http://b.atch.se as soon as I have had time to write the contents of new posts.

    Comment linking /

    on “How to implement a constant-expression counter in C++”
  11. This is the second post in the series regarding "non-constant constant-expressions in C++" - http://b.atch.se/posts/non-constant-constant-expressions/ Feedback is more than welcome! /Filip Roséen

    Comment linking /posts/non-constant-constant-expressions/

    on “How to implement a constant-expression counter in C++”
  12. For those who are looking to understand what is going on, I would recommend the blog series I wrote -almost- more than half a decade ago at https://b.atch.se Compiler intrinstics havet changed a lot since then, but the wording in the standard remains quite stable in this department Disclaimer; I did not read your post in full (on set, working atm). Edit: time flies, it has been more than half a decade.

    Comment linking /

    on “The C++ Type Loophole (C++14)”
  13. I believe this trick (auto constexpr definition using friend injection) was first described in this post https://b.atch.se/posts/non-constant-constant-expressions/

    Comment linking /posts/non-constant-constant-expressions/

    on “The C++ Type Loophole (C++14)”
  14. A detailed post that shows how to implement a stateful meta-container that is usable where a constant-expression is required, effectively making it possible to store away different states during compilation of a program. The approach enables the world of meta-template programming to closely follow the semantics of imperative programming. This post is part of the series regarding non-constant constant-expressions in…

    Comment linking /posts/non-constant-constant-expressions/

    on “How to implement a compile-time meta-container in C++”
  15. I was implying a compile-time solution, i.e. where the result of the mapping is constexpr. On second though, maybe it can be done at compile time, with this: http://b.atch.se/posts/constexpr-counter/

    Comment linking /posts/constexpr-counter/

    on “Mapping Types to Values (in C++)”

Search all of HN for b.atch.se