CTAD and concepts in C++20

Hi all, hope you're all very good.

Stroustrup says: "Whenever possible use named concepts (e.g., standard-library concepts)", but I have a guess for the time being that standard concepts are a wrapper arround type traits. Example: std::integral:
1
2
template < class T >
concept integral = std::is_integral_v<T>;
So why not just use that wider category (which is the type traits) instead of the so-called standard concepts? (this is againgst what Stroustrup says apparently).

My second question is, for a restriction on a template arguments, we are to firstly search for that on standard concepts or type traits and then when there's no such an already defined restriction we go for defining a concept for that. Example: Printable. Right?

My third question referes to CTAD. What tut do you recommend for studying it using C++20, of course except for cppreference (which is very vast and complicated)?

My last question is: Is it true that we may rarely need CTAD guides for C++20?
Last edited on
So to answer my questions:
1) We had better use standard concepts not only because there're shorter (when typing) but because it's possible to write:
template <std::integral T> but not template <std::is_integral_v<T> T> or like that!

2) Yes.

3, 4) We are to write CTAD guides even when using C++20 if the class is not an aggregate.
Last edited on
Topic archived. No new replies allowed.