From this question Why can't I construct a queue/stack with brace-enclosed initializer lists? (C++11), we know that it won't work by constructing a queue with single curly braces. Because queue is container adapter which does not have constructor with initializer list.
However, why below approach will work? Does double curly braces call queue's constructor with container argument? So the inner curly brace {"hello"}
is considered as a vector<string>
?
queue<string> q{{"hello"}}; //Question: why init with double curly braces?