************************************************************************************** Status of C++11 features relevant to EECS 381 Projects in MSVS, Xcode, and g++ 4.7.0 Last updated: 09/21/2012 ************************************************************************************** The web has many "feature charts" of C++11 implementation status of various compilers & libraries, but these are often out of date and lacking in detail. This document describes the status of things relevant to the course projects. Let me know if you discover anything relevant to this document to help me keep it up to date. g++ using gcc 4.7.0 with -std=c++11 is the "standard" environment for the course; it is available both on CAEN and is what the autograder uses. Unless specifically stated otherwise, everything presented, recommended, or required in the course compiles and runs correctly in gcc/g++ 4.7.0. But some noteworthy things that work are pointed out. Problems are prefixed with ---, noteworthy things that work with +++ If the document says something doesn't work, it means it won't compile - a fatal error results. ======== MSVS 2012 ============ --- Move semantics related. Does not accept the =default or =delete for class member functions for copy/move construction or assignment. It thinks you are trying to define a pure virtual function, and inconsistent error messages then appear. Workaround: Instead of =delete, use the technique of declaring the member function private without supplying an definition. No good workaround for =default, but hopefully it won't produce a visible effect in the course projects. See below about using both MSVS and g++. +++ Function objects for use in algorithms can be declared in the function scope, which is preferable if that function is the only place the function object will be used (the principle of declaring something in the narrowest scope possible). --- Brace initialization of a map not supported; probably other containers as well. Workaround: initialize with explicit calls of member functions, like [] or insert for a map, push_back for a vector (like in C++98). +++ Lambdas work! ---------- Using Both MSVS and g++ ----------------- Use conditional compilation with the preprocessor to have your code automatically adapt to the platform by detecting the presence of a preprocessor variable defined only in the MSVS implementation. For example, to use the same code file in both MSVS and g++, put in the following #if statements: #ifdef _MSC_VER put in here code you only want to use in MSVS #endif #ifndef _MSC_VER put in here code you only want to use in non-MSVS environment, like CAEN g++ or Xcode #endif ======== XCode 4.4.1, with OS 10.8.1, LLVM compiler 4.0, C++11, and libc++ ======== +++ Function objects for use in algorithms can be declared in the function scope, which is preferable if that function is the only place the function object will be used (the principle of declaring something in the narrowest scope possible). +++ brace-initialization of a map container works. --- Move semantics related. map.insert(make_pair etc) appears to require that the object in the second of the pair have move construction or assignment defined (compiler error if =delete). Work-around: go ahead and define the move functions, if the compiler defaults are OK, let them work. Not clear whether this is a bug in the compiler, library, or actually a C++11 requirement. +++ Lambdas work!