I am reading the Scoped enumerations page from here:
So I decided to give it a try:
$ cat e.cxx
#include <cstdint>
enum class Handle : uint32_t { Invalid = 0 };
int main()
{
Handle h { 42 }; // OK
return 0;
}
$ g++ -std=c++11 e.cxx
e.cxx: In function ‘int main()’:
e.cxx:5:17: error: cannot convert ‘int’ to ‘Handle’ in initialization
Handle h { 42 }; // OK
^
Using:
$ g++ --version
g++ (Debian 5.3.1-14) 5.3.1 20160409
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If I now check the C++11 support in GCC, it appears as if everything is supported since GCC 4.8.
So which page am I reading it wrong ? The example for Score enumertions is not 100% correct, or the support for C++11 in GCC is still incomplete ?
Aucun commentaire:
Enregistrer un commentaire