With 'modern C++' you can make APIs way nicer than the Java-like API going on here. Lambdas really help, along with RAII which has already been around. I have an API going where the following syntax creates a div with a 'toolbar' class and a toggle button with the 'edit' class and updates the DOM (C++ running in WASM, using IncrementalDOM for the DOM access):

  ui.div()("toolbar")([&]() {
    ui.button()("edit")("selected", editing)("click", [&](emscripten::val target) {
      editing = !editing;
    });
  });
This works by having `.div()` etc. return an `Elem` type whose constructor opens an HTML element and destructor closes it, with various overloads of `operator()` letting you set attributes, bind events or add child elements.

Here's a video of some results with C++ and CSS: https://twitter.com/snikhilesh/status/1279913032471031809

I should do a writeup about this soon...

Cool, but this is gibberish.

I'm fine with that rn cuz the use case is a personal API for me making game tooling UI on a side project, still kind of experimental.

It's basically what the JS that gets generated from React JSX is like, and also like immediate mode UI APIs that get used for game tooling a lot: https://github.com/ocornut/imgui