Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto in function parameter list implying template argument

In his talk at cppcon (~13 mins in), Andrew Sutton mentions that you will "soon" be able to write

auto func(auto a, auto b) { ... }

which will be taken to mean

template <typename T, typename U> auto func(T a, U b) { ... }

just as was introduced for generic lambdas in C++14.

  1. What is the name for this feature?

  2. Is this a part of Concepts Lite, or was it proposed separately?

  3. This obviously didn't make it into C++14 if it was indeed proposed; if anybody knows, what were the objections raised against it?

like image 818
Tristan Brindle Avatar asked Oct 20 '14 05:10

Tristan Brindle


People also ask

Can we use non type parameters as argument templates?

A non-type template argument provided within a template argument list is an expression whose value can be determined at compile time. Such arguments must be constant expressions, addresses of functions or objects with external linkage, or addresses of static class members.

What is template argument list?

A template argument for a template template parameter is the name of a class template. When the compiler tries to find a template to match the template template argument, it only considers primary class templates. (A primary template is the template that is being specialized.)

What is a template template parameter in C++?

In C++ this can be achieved using template parameters. A template parameter is a special kind of parameter that can be used to pass a type as argument: just like regular function parameters can be used to pass values to a function, template parameters allow to pass also types to a function.

Can template have default parameters?

Template parameters may have default arguments. The set of default template arguments accumulates over all declarations of a given template.


1 Answers

  1. Abbreviated Function Templates
  2. Yes, it's part of Concepts Lite
  3. It's in the concepts TS, which was nowhere near being ready for C++14.

Read all about it in the latest draft of the concepts TS.

like image 182
Casey Avatar answered Oct 14 '22 06:10

Casey