# Advent of Code in C++ Template Metaprogramming

DevFeed: [Advent of Code in C++ Template Metaprogramming](<https://devfeed.tech/articles/advent-of-code-in-c-template-metaprogramming-21942.md>)

Original publisher: [Read original article](<https://blog.nelhage.com/post/advent-of-templates/>)

Author: Nelson Elhage

Published: 2023-12-08T15:30:00Z

Content type: tutorial

Language: en

Sources: [Nelson Elhage](<https://devfeed.tech/sources/nelson-elhage.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Code](<https://devfeed.tech/topics/code.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [polyfill](<https://devfeed.tech/topics/polyfill.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [polyfill](<https://devfeed.tech/tags/polyfill.md>), [writeup](<https://devfeed.tech/tags/writeup.md>)

## AI overview

An annotated walkthrough of solving the first Advent of Code problem using purely compile-time C++ template metaprogramming. It covers compile-time input handling, folds, helper types, and state tracking to calculate calibration values.

## Source excerpt

This December, the imp of the perverse struck me, and I decided to see how many days of Advent of Code I could do purely in compile-time C++ metaprogramming. As of this writing, I've done two days, and I'm not sure I'll make it any further. However, that's one more day than I planned to do as of yesterday, which is in turn further than I thought I'd make it after my first attempt.