C++ auto keyword. Why is it magic?

auto was a keyword that C++ “inherited” from C that had been there nearly forever, but virtually never used because there were only two possible conditions: either it wasn’t allowed, or else it was assumed by default. The use of auto to mean a deduced type was new with C++11. At the same time, auto … Read more

Arrow operator (->) in function heading

In C++11, there are two syntaxes for function declaration:     return-type identifier ( argument-declarations… ) and     auto identifier ( argument-declarations… ) -> return_type They are equivalent. Now when they are equivalent, why do you ever want to use the latter? Well, C++11 introduced this cool decltype thing that lets you describe type of an expression. So … Read more

What does auto&& tell us?

By using auto&& var = <initializer> you are saying: I will accept any initializer regardless of whether it is an lvalue or rvalue expression and I will preserve its constness. This is typically used for forwarding (usually with T&&). The reason this works is because a “universal reference”, auto&& or T&&, will bind to anything. … Read more

How much is too much with C++11 auto keyword?

I think that one should use the auto keyword whenever it’s hard to say how to write the type at first sight, but the type of the right hand side of an expression is obvious. For example, using: my_multi_type::nth_index<2>::type::key_type::composite_key_type:: key_extractor_tuple::tail_type::head_type::result_type to get the composite key type in boost::multi_index, even though you know that it is … Read more

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