jeudi 28 avril 2016

c++11 uniform initialization doesn't work with "g++ -std=c++0x"

I have a class that declares this public method:

virtual std::vector<float> operator()(const std::vector<float>& = {});

which uses uniform initialization (here just {}), a feature from c++11. This doesn't give me any problem when compiling with clang++ -std=c++11. But when I use g++ -std=c++0x I get this:

error: expected primary-expression before '{' token

Isn't the -std=c++0x option supposed bring me c++11 support?

The compiler doesn't give me any error when declaring the method using standard c++ like this:

virtual std::vector<float> operator()(const std::vector<float>& = std::vector<float>());

I am using g++ 4.6 on Ubuntu 12.04

Aucun commentaire:

Enregistrer un commentaire