Could not convert from brace-enclosed initializer list to std::vector

I saw a lot of similar questions, but I don't think I saw quite the same one. It's pretty basic. Some code from my lecturer is failing to compile, and I distilled the problem to this test case:

void foo(vector<int> v) {

void fooUsage() {
    foo({0, 1, 2});

This fails with:

could not convert '{0, 1, 2}' from '<brace-enclosed initializer list>' to 'std::vector<int>

Note: It works on GCC 5.0.0 20141228 but fails on my GCC 4.7.1 (tdm-1).

Sorry if this is too basic but I don't know C++11 very well.


This is a known bug that was fixed in gcc 4.8.

Need Your Help

What is the difference between multiple implementations of ArrayList in the (Java8) source code

java arraylist java-8

I was trying to understand Streams in Java8 and intermittently I stumbled upon an interesting thing in the source code of Java8: ArrayList seems to be implemented twice:

How to group by multiple columns with complex types in Linq

c# sql linq entity-framework grouping

I'm trying to preform a group by to get all of the students, by college, grouped by status. The problem is the database I'm working with has hundreds of fields in the StudentInfo table, which is wh...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.