Daniel Lemire's blog

, 2 min read

Generating arrays at compile-time in C++ with lambdas

3 thoughts on “Generating arrays at compile-time in C++ with lambdas”

  1. Nice, looks like one of the patterns we’ve ended up developing and using all over in the Carbon toolchain!
    https://github.com/carbon-language/carbon-lang/blob/trunk/toolchain/lex/tokenized_buffer.cpp#L85-L95

    If you’re looking at any of the Carbon toolchain, always happy to chat / answer questions / etc on our Discord (or via email). Cheers!

  2. Todd Lehman says:

    This is really cool!
    It doesn’t sound like memoization to me, though. I think this is just an ordinary lookup vocabulary an immutable table (albeit an optimized one in the case of a bit-test instruction). Memoization is about caching values as they are discovered and requires the use of a mutable table to cache the newly discovered values over time.

    1. Nathan Myers says:

      Right, this is more akin to what they used to call “dynamic programming”.