As per the cppreference, there is void push(value_type&& value );. But when I optimized my code on visual studio 2017 with C++17 option, I found g_queue.push(std::move(element)) actually calls std::queue::push(const value_type&) other than std::queue::push(const value_type&&) .
For me, the value_type(i.e T) for the queue is std::vector<char>.
What a surprise that there is no std::queue::push(const value_type &&) for MSVC!
And as per the MSDN, it seems there is no std::queue::push(value_type&&) indeed.
UPDATE:
I looked the header for std::queue which is implemented by MS. There is no void push( value_type&& value ) indeed.Header path is c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\queue line 130!
And the Perfomance Profiler could not cheat me too, it really calls std::queue::push(const value_type&) .
A demo snippet is on the way at once.Please give me two minutes.
Here is the demo code
#include<vector>
#include<queue>
#include<string>
int main()
{
std::queue<std::vector<char>> queue;
std::string str = "I need some help, thanks.";
std::vector<char> vec(str.begin(), str.end());
//The `Perfomance Profiler` provied by VC2017 could not cheat me too.
//It really calls std::queue::push(const value_type&).
queue.push(std::move(vec));
}
Aucun commentaire:
Enregistrer un commentaire