Forum Replies Created
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
16. June 2022 at 09:52 in reply to: Extend bigArray exercise by calling push_back() and emplace_back() #11763::
To extend the discussion:
// in this case, it does not use the move semantic? std::cout << std::endl; std::string_view strView{"blahh"}; std::cout << "&strView: " << &strView << '\n'; auto str5 = std::move(strView.data()); std::cout << "str5: " << str5 << '\n'; std::cout << "&str5: " << &str5 << '\n'; auto str6 = std::move(strView.data()); std::cout << "str6: " << str6 << '\n'; std::cout << "&str6: " << &str6 << '\n'; std::cout << "strView: " << strView << '\n'; std::cout << "&strView: " << &strView << '\n';
::There is one interesting point that explicitly advocates for using auto in the cpp core guidelines:
<h3 id=”es11-use-auto-to-avoid-redundant-repetition-of-type-names”>ES.11: Use <code class=”language-plaintext highlighter-rouge no-highlight”>auto to avoid redundant repetition of type names</h3>
My question to Rainer:When you declare a type using auto, the compiler will define its type by taking it out from the definition? Like:
auto firstVar = 1.2; // double
auto secondVar = 1.2f // float
? If yes, then you need to really take care to avoid type promotions…?
By definition, if you use auto everywhere, then you will be enforcing
<h3 id=”es20-always-initialize-an-object”>ES.20: Always initialize an object</h3> -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)