Skip to content

Making a Convenient API With Metaprogramming - Ruslan Arutyunyan

Photo of Jason Turner
Hosted By
Jason T. and Ben D.
Making a Convenient API With Metaprogramming - Ruslan Arutyunyan

Details

Modern C++ gives us plenty of metaprogramming power but turning that power into an intuitive, "just works" API can sometimes be tricky. I'll run a live-coding session where we take a single, deceptively simple task - designing a constructor that accepts both explicit arguments and/or braced-init-lists - and walk it from naive attempts to a production-ready solution.

You'll see, step-by-step why straightforward ideas (parameter pack, `std::initializer_list`, C-style arrays) fall short, and how a relatively simple - yet, interesting - set of template techniques comes together to produce a much better interface with improved usability. We also explore the limits of Class Template Argument Deduction (CTAD) in this context and show how to patch the gaps with a minimal, readable deduction guide.

Attendees will keep the tricks up their sleeves and they can drop into their codebases for when meet similar tasks without a fear of using templates. Plus, I hope to give the audience a better understanding of how to use metaprogramming to make the users, not just the compiler, happy.

---------

There is a discord for the meetup that you can join https://discord.gg/98T5XPWcrA to help foster remote interaction!
We always plan to go to the Burns pub for social hour after the presentation.

--------

We have no food sponsor at the moment.

Thank you to our sponsors:

  • Trimble for event space and soft drinks
Photo of Denver C++ Meetup group
Denver C++ Meetup
See more events
FREE