# Who's Afraid ## of the # Big Bad Template<>? ## Talk<"Coral Kashri", "Solidus">();
# Who am I? :) ## Coral Kashri (She/Her) * Senior C++ Developer * [C++ Senioreas](https:://cppsenioreas.wordpress.com) blog writer * ISO C++ committee member

The Big Bad Template

There was a little 🏒, and this 🏒 had an intelligent CTO who just hated templates <😈>.

There was always the assumption that 😈s are difficult to maintain and that it's much harder to πŸ•΅πŸΌβ€β™€οΈ someone who πŸ’‘ how to πŸ’» with them.

At the <- it all seemed so easy, as the idea was simply πŸ’‘πŸ’‘πŸ’‘ - to create a list of πŸ“ to collect in the 🌲🌲 before going out and forgetting what was needed.

So their technology looked like that:



After completing the product, there was no need for a team to πŸ› οΈ it, and the team was able to std::move std::forward to other technology challenges.

⌚ πŸšΆπŸ½β€β™€οΈ by, and the invention of a new modern 🧺 aimed to destroy the company's πŸ₯‡s.
A modern 🧺 that can contain up to 10 πŸ‡ at the same time!

But the company CTO was not about to 🏳️, she moved her team back to this product and together created a newer list named modern_basket:

The new πŸ’‘ πŸ‘†πŸ½ the company's stock price πŸ“ˆ, and everything seemed so peaceful for the company, until a newer πŸ’‘ got the attention of the 🌎.

A πŸ›’!

This πŸ›’ was able to contain up to 50 (🀯) πŸ„β€πŸŸ«s at the same time.
The CTO was 😫.

She and the team πŸ”Ž it frustrating to create each time a new moderner modern container.
She knew they needed something 🧠, more dynamic, and flexible.
And in times of despair, she decided to do the inevitable upgrade to their architecture:

The End

Templates? Metaprogramming?

  • Templates are part of Metaprogramming
  • constexpr, consteval
  • Advanced templates: Variaic template, fold-expressions, concepts...
  • C++ Metaprogramming is a Turing-Complete language

NTTP vs. TTP

NTTP Main Restrictions

  • All structure's members (and their members) should be known at compile-time
  • All structure's members (and their members) should be public
  • Does std::string_view can be used as NTTP?

std::string_view Implementation

NTTP friendly FixedString

NTTP friendly FixedString

Shopping Time!

Grocey Interface

Grocery Items

Creating A Bag

Creating a Cart

Adding UDL

User Defined Literals - 30_sec Remainder

Adding UDL

The rule I'll ignore

Any UDL should start with a single underscore ('_'), otherwise it's reserved for the standard library implementors.

Adding UDL

Combining it all together

But WAIT!

Let's level it up a little

Completely Compile-Time Program!

What is our target?

Making Compile-Time Bag

Making Compile-Time Bag

Core Change to Cart

What is std::tuple?

  • tuple is an extended std::pair, can hold an inifinite number of types.
  • The choise to which element we want to access should be done at compile-time.

When using typed get access, all the tuple's types have to be unique.

Cart Implementation Time

Cart Implementation Time

Minor UDL modification

The Result

# Questions Time! ## Who's Afraid of the Big Bad Template? | | Coral Kashri, Solidus | | :--------------------------------------: | :-----------------------: | | πŸ“¬ | coralkashri@gmail.com | | ![](dist/assets/linkedin.png#center) | Coral Kashri |