У C++20 зʼявились концепти й обмеження для функцій, класів/структур та інших шаблонів. Для функцій та методів вимоги можна вказувати після оголошення шаблону або після функції.

template<typename T> requires ... T f() {} template<typename T> T f() requires ... {}

Якщо не шаблонний метод у шаблоні класу потребує додаткових вимог їх можна вказати після оголошення методу.

template<typename T> class S { T f() requires integer<T> {} };

У такому випадку клас може згенеруватись з будь-яким типом, але це метод буде присутній тільки якщо шаблонний тип відповідає вимогам.

Але іноді може знадобитись використати поточний клас у вимогах. Наприклад при CRTP.

template<typename D> class Base requires std::derived_from<D, Base> {...};

На жаль зараз такого немає.

#cpp #cxx #cpp20 #concepts #constrains #requires #class #template #struct #CRTP #proposal #програмування #шаблони #вимоги #обмеження #пропозиція

Social.Net.Ua

Dear Friends of FReedom,
As we may know, France and freedom have many
#possibilities that the #enchanted, #entrapped and drones are trying to work.
For Example:
- Food grows with trees
🌱
- Nobody impoverishes
#knowledge 📚
- She-shee sushhh
🤫
In other words, look, listen, learn to be a LLL. If we know,
#share. What we the people R is #indefatigable.

How do I know?
1. By Knowing my sources and sauces. Food Done.
😌
2. Bye knowing by
#tolled, #tithed and told. 🫡
3. Buy less is a
#given. Make more use. 😶

So our
#expectations and #capacities #servers #reminders. Language #transmits, knot #constrains. 🫶

Unleashing your creativity with #ChatGPT

I've created 3 short videos that show OpenAI's cutting-edge #AI technology for #Code creation, #Content generation, and more use cases including the exploration of its #Constrains 👉 https://www.reply.com/en/artificial-intelligence/unleashing-your-creativity-with-chatgpt

#LLM #DeepLearning #OpenAI

Unleashing your creativity with ChatGPT | Reply

A video guide to harnessing OpenAI's Cutting-Edge AI Technology for code creation, content generation, and more use cases including the exploration of its constrains.

Reply