undefined behaviour somewhere in boost::spirit::qi::phrase_parse

You cannot use auto to store parser expressions¹ Either you need to evaluate from the temporary expression directly, or you need to assign to a rule/grammar: const qi::rule<std::string::const_iterator, qi::space_type> doubles_parser_local = qi::double_ >> *(‘,’ >> qi::double_); You can have your cake and eat it too on most recent BOost versions (possibly the dev branch) there … Read more

C++ auto vs auto&

The type deduction for auto works exactly the same as for templates: when you deduce auto you will get a value type. when you deduce auto& you wil get a non-const reference type when you deduce const auto& you will get a const reference when you deduce auto&& you will get a non-const reference if … Read more

Does a declaration using “auto” match an extern declaration that uses a concrete type specifier?

There’s surprisingly little in the standard about this. About all we hear about redeclaration is: [C++11: 3.1/1]: A declaration (Clause 7) may introduce one or more names into a translation unit or redeclare names introduced by previous declarations. [..] and the only relevant part of auto‘s semantics: [C++11: 7.1.6.4/3]: Otherwise, the type of the variable … Read more

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

C++ auto& vs auto

auto and auto && cover most of the cases: Use auto when you need a local copy. This will never produce a reference. The copy (or move) constructor must exist, but it might not get called, due to the copy elision optimization. Use auto && when you don’t care if the object is local or … Read more