0

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?

Praetorian
  • 103,386
  • 18
  • 232
  • 318
DarenW
  • 16,172
  • 7
  • 61
  • 100

3 Answers3

4

Try this one,

auto f = [](){};

or write some code with rvalue reference.

imlyc
  • 84
  • 5
  • I'm not entirely sure this is correct, but from what I'm reading in 2019, it looks like that in the upcoming C++20, []<>(){} will be legal. – DarenW Jul 16 '19 at 05:02
3

Shortest thing possible:

[]{};

Is's a lambda-expression without argument list.

HolyBlackCat
  • 63,700
  • 7
  • 105
  • 170
3

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).

MikeMB
  • 18,817
  • 9
  • 54
  • 98
  • Can someone mark it as duplicated of: http://stackoverflow.com/questions/5047971/how-do-i-check-for-c11-support – dau_sama Jan 17 '15 at 10:31