I found out, that GCC 5.1
allows types like list<auto>
as function and lambda parameter types. While this feature is really interesting and even useful, I couldnt find any extensions or standards that explain this behavior.
Is there any explanation on GCC
's side about this feature?
I made an easy type switch as an example:
#include <iostream>
#include <vector>
#include <typeinfo>
#include <tuple>
using namespace std;
void matchType(const tuple<auto,auto,auto>& x){
cout << "its a tuple<auto,auto,auto>" << endl;
}
void matchType(const tuple<auto,auto>& x){
cout << "its a tuple<auto,auto>" << endl;
}
void matchType(const vector<auto>& x){
cout << "its a vector<" << typeid(typename decay_t<decltype(x)>::value_type).name() << ">" << endl;
}
void matchType(const auto& x){
cout << "its a " << typeid(x).name() << endl;
}
int main(){
matchType(make_tuple(23,55,11));
matchType(make_tuple("hey","it works"));
matchType(vector<string>{});
matchType(vector<int>{});
matchType("test");
}
output:
its a tuple<auto,auto,auto>
its a tuple<auto,auto>
its a vector<NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE>
its a vector<i>
its a A5_c