Don't std::move the return value. Let the return value optimization do the work for you.
It's the fastest method. My Respect for great idea
Pro number 1 : auto uses type deduction which simplifies life considerably.
Pro number 2: auto forces you to initialize a variable hence you can’t forget doing that. Statement “auto x” is illegal.
Pr0 number 3: If you change datatypes afterwards (eg int to float), you need to change it less times
Con: Referring to pro number 1 “Our virtues and our failings are inseparable” :) auto may deduce type incorrectly, but luckily it’s hard to trick it. One such case is
See also: https://stackoverflow.com/questions/6434971/how-much-is-too-much-with-c11-auto-keyword https://stackoverflow.com/questions/6900459/the-new-keyword-auto-when-should-it-be-used-to-declare-a-variable-type
but what's the advantage of using "auto"??
Thanks for the explanation DarkD1 👍
and sometimes c++ gives up(std::vector <auto>)
It tells C++ to try and automatically detect the type.
Hey man! What does "auto" do??
Game changer is this line: "auto i = mapping[w];". I didn't know you can do that, that's helpful. Also, clever solution.
It is a smart solution, because it uses the standard library, but one of the slowest ones.
It creates an unnecessary temporary object with significant overhead.
Overal solution is 1.5 times slower than a table lookup algorithm and 2.5 times slower than parallel bits counting algorithm.
I would not recommend it as a best practices.
Why are the examples removed from the description?
When transferring references to std::thread, I had to use std::ref.
Otherwise, a copy of the object was created in the thread.
chars are printed as characters by default, which isn't helpful here. You can use a custom stringizer: https://github.com/banditcpp/snowhouse#getting-better-output-for-your-types
(Although if it works for other types, it probably works for chars, so I don't see a need to test chars, but I don't see a need to print them correctly either.)
Negative numbers should be in fixed tests too.
Undeclared identifiers: srand, time etc.
Kind of, but class template arguments must be deduced to call it and decudction rules are different for classes.