/home/bill/System_maintenance/cpp compiler auto declaration of variables.txt **************************** 03Jul2017 13:13 while working on opm-core build Great comments!!! : https://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/ GotW #94 Solution: AAA Style (Almost Always Auto) 2013-08-12 by Herb Sutter JG Questions 1. What does this code do? What would be a good name for some_function? template void some_function( Container& c, const Value& v ) { if( find(begin(c), end(c), v) == end(c) ) c.emplace_back(v); assert( !c.empty() ); } 2. What does “write code against interfaces, not implementations” mean, and why is it generally beneficial? Guru Questions 3. What are some popular concerns about using auto to declare variables? Are they valid? Discuss. 4. When declaring a new local variable x, what advantages are there to declaring it using auto and one of the two following syntaxes: (a) auto x = init; when you don’t need to commit to a specific type? (Note: The expression init might include calling a helper that performs partial type adjustment, such as as_signed, while still not committing to a specific type.) (b) auto x = type{ init }; when you do want to commit to a specific type by naming a type? List as many as you can. (Hint: Look back to GotW #93.) 5. Explain how using the style suggested in #4 is consistent with, or actively leverages, the following other C++ features: (a) Heap allocation syntax. (b) Literal suffixes, including user-defined literal operators. (c) Named lambda syntax. (d) Function declarations. (e) Template alias declarations. 6. Are there any cases where it is not possible to use the style in #4 to declare all local variables? # enddoc