I've tried the C++0x initializer-list implementation of my G++ version but it outputs only empty lines.
#include <initializer_list>
#include <iostream>
#include <string>
int main() {
std::initializer_list<std::string> a({"hello", "stackoverflow"});
for(auto it = a.begin(), ite = a.end(); it != ite; ++it)
std::cout << *it << std::endl;
}
I have no idea what I did wrong. Can anyone help me out please?
If I declare that as:
then it's working : http://ideone.com/21mvL
But that is weird. Looks like its a compiler bug.
EDIT:
Its most certainly a compiler bug, because if I write
(*it).c_str()it prints the strings!!Code : http://ideone.com/hXr7V