Can concepts replace all other instances of the template keyword?

Is it possible to use C ++ concepts to replace all keyword expressions template
(except the notion of own declaration)?

I am curious if there are any reasons, still need to use the keyword templatefor other language constructs such as template classes or template functions. The only exception I can think of is template type aliases. The use of templates for compilation time calculations can be replaced with functions constexpr.

To keep my question short,
What can regular template declarations do that accepting concepts + constexpr cannot replace?

+4
source share
2 answers

Your premise is a bit loaded. Although you can convert the old syntax for templates (for the same function templates, classes, variables, or aliases) by introducing a concept, in many cases it makes it artificial and passes the baton. Take the classic function template as std::transforman example:

// current
template<typename In, typename Out, typename Func>
Out transform(In first, In last, Out out, Func func);

You can convert it to use the concept, and not in a very obvious way:

TransformParameters{In, Out, Func}
Out transform(In first, In last, Out out, Func func);

, , : , TransformParameters - ? . , - , / .

, std::transform ( , Im , ):

template<Iterator In, Iterator Out, Value Func>
    requires
        Callable<Func, iterator_reference_t<In>>
        && AssignableFrom<
            iterator_reference_t<Out>,
            result_of_t<Func(iterator_reference_t<In>)>
        >
Out transform(In first, In last, Out out, Func func);

, , , std::transform *out = func(*in). , , -, , ( std::result_of_t ).

, . require , , iterator_reference_t<…> result_of_t<…>, (, It Iterator Callable).

, .. , ; . ( , .)

+4

template

template some_class<int>;

obj.template fun<T>();
+6

Source: https://habr.com/ru/post/1608760/