DarenW
DarenW

Reputation: 16906

What's a quick simple bit of code to verify a given C++ compiler is reading source as C++11?

I think my compiler understands C++11, but maybe not. Instead of trying it on existing messes of source code which are buggy anyway, is there some simple "hello world" level snippet of source code I can try to compile, which if it does compile without error, proves the compiler is reading it as C++11?

Upvotes: 0

Views: 177

Answers (3)

MikeMB
MikeMB

Reputation: 21156

The Problem is that compiler usually don't support a new standard completely from the start. Meaning, they may support one c++11 feature, but not another.

However, as far as c++11 is concerned, I think VC++ is the only major compiler that doesn't fully support it, even though you may have to enable the c++11 mode manually. For g++ you e.g. have to supply the compiler flag -std=c++11 (or -std=gnu++11) - the same holds true for newer versions like c++14).

Upvotes: 3

HolyBlackCat
HolyBlackCat

Reputation: 96286

Shortest thing possible:

[]{};

Is's a lambda-expression without argument list.

Upvotes: 3

imlyc
imlyc

Reputation: 84

Try this one,

auto f = [](){};

or write some code with rvalue reference.

Upvotes: 4

Related Questions