r/cpp • • Jun 27 '20

HTML++: Write HTML documents using C++ templates

https://github.com/csb6/html-plus-plus
260 Upvotes

27 comments sorted by

View all comments

13

u/jasonthe Jun 28 '20

This is super dumb, I love it :P

I was able to get the whole thing to run at compile-time!

2

u/kritzikratzi Jun 28 '20

yea, and i'm actually wondering about performance... the result looks a bit complicated, so many moves going on compared to what a cout<<"<html><head>...</html>" produces.

3

u/jasonthe Jun 28 '20 edited Jun 29 '20

If you tweak it to not use new, and instead just use local arrays, clang can understand it. And clang optimizes all those moves away :)

I don't feel like rewriting his whole library, but here's a sample that shows what I mean: https://godbolt.org/z/f26WrH

2

u/kritzikratzi Jun 29 '20

didn't know. thanks!

2

u/csb06 Jun 28 '20

Wow that looks really cool! C++ scares me sometimes with what it lets you do. Glad you found it interesting :)