Is there a way to pass auto as an argument in C++?

C++20 allows auto as function parameter type This code is valid using C++20: int function(auto data) { // do something, there is no constraint on data } As an abbreviated function template. This is a special case of a non constraining type-constraint (i.e. unconstrained auto parameter). Using concepts, the constraining type-constraint version (i.e. constrained auto … Read more

A lambda’s return type can be deduced by the return value, so why can’t a function’s?

C++14 has this feature. You can test it with new versions of GCC or clang by setting the -std=c++1y flag. Live example In addition to that, in C++14 you can also use decltype(auto) (which mirrors decltype(auto) as that of variables) for your function to deduce its return value using decltype semantics. An example would be … Read more

Does ‘auto’ type assignments of a pointer in c++11 require ‘*’?

auto newvar1 = myvector; // vs: auto *newvar2 = myvector; Both of these are the same and will declare a pointer to std::vector<MyClass> (pointing to random location, since myvector is uninitialized in your example and likely contains garbage). So basically you can use any one of them. I would prefer auto var = getVector(), but … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)