Visual studio 2013 to compile strict c++11 - c++

As cited here Visual c++ 2013 supports most of c++11, plus some extra features and some changes. However, I need to be able to write and compile strictly in c++11. Is there a package that only contains c++11 headers or some other setting that I can implement to make visual studio work in c++11? I have looked at this link question but it isn't exactly what I want. Also I do not have an older version to change the framework to as suggested. Thank you.

No, you can't do that. Compliance to C++11 isn't just a matter of headers. It requires a fully-compliant compiler. If you use VS2013, you'll need to settle for the supported subset of C++11 features.

Related

Visual Studio 2017, experimental/optional - No such file or directory [duplicate]

I want to use std::experimental::optional, but MSVS 2013 tells me it can't find the header.
Why isn't it there?
Can I roll my own based on code elsewhere? The C++14 proposal maybe?
std::experimental::optional originates from the Boost.Optional library, and this implementation works well in Visual C++ 12.0 (though it differs a little). Reference single-header implementation, based on the N3793 proposal paper, can be found here.
The latest list of supported C++11/14/1z core and library features that are shipped with Visual Studio can be found from the Visual C++ Team blog, from this post in particular. A set of header files of the Standard Library implementation (and some extensions) from Microsoft can be viewed here.
I've found that this implementation compiles with MSVC2013. Note that only compiles, everything else isn't guaranteed.
https://github.com/mapbox/variant/blob/master/include/mapbox/optional.hpp
I was using this one for msvc2015 and it worked:
https://raw.githubusercontent.com/akrzemi1/Optional/master/optional.hpp

How to "activate" c++11 standard in visual studio 2010?

I am new to c++ programming and I need to use the Thread class in my VS 2010 project.
I've found this reference, but when I try the following:
#include <thread>
VS 2010 obviously tells me 'Error: cannot open source file "thread"'. I understand that I need to "activate" c++11 standard somehow. I do not even know where to start.
So what should I do to use () c++11 standard in visual studio 2010?
std::thread is obviously not in VS 2010. I think it was added with VS 2012, which is also supported by this question and answer. Is there any specific reason you're using 2010 rather than the latest version, 2013, which supports far more part of C++11?
Also to note: Contrary to GCC, MSVC doesn't have an "opt-in" for newer standards. It just supports them out of the box as far as implemented.
The Visual C++ compiler is not fully C++11 compatible. C++11 features had been supported since Visual Studio 2010 and added incrementally. Not even the next version of Visual Studio will provide full C++11 compatibility. A matrix of C++11 features available in different versions of Visual Studio can be found here:
C++0x Core Language Features In VC10: The Table
C++11 Features in Visual C++ 11
C++11/14 STL Features, Fixes, And Breaking Changes In VS 2013
C++11 is enabled by default, but there is not many features implemented in VS 2010. C++11 standard library is missing many headers in VS 2010. Here is a comparison of a last few VS releases regarding the C++11 support.
Here's what I've found by myself.
To "activate" c++11 in visual studio you need to set "Platform Toolset" in project->properties to v110 or above. So that's how visual studio will understand that it should use c++11 features.
BUT!
The Visual C++ compiler is not fully C++11 compatible. C++11 features had been supported since Visual Studio 2010 and added incrementally. Not even the next version of Visual Studio will provide full C++11 compatibility.
Marius Bancila
So it worked for <thread> (and <future>) in visual studio 2012.
As I suggest it's impossible to set Platform Toolset above v100 in vs2010, so it's impossible to "activate" c++11 in vs2010.
Conclusion:
to use c++11 standart features in visual studio you will need to use 2012 and higher version which supports Platform Toolset v110 and above.
Correct me please if I'm wrong!
d= (◕‿↼ ) C++11 is enabled by default, But unfortunately, not even "Visual Studio 2017" is fully C++11 compliant.
(I got here while building Boost, which's build section only mentions their need for C++11 compliant compiler, and NOT with what MSVC version they tested Boost.)
Microsoft says:
"Support for C11 and C17 standards is available in Visual Studio 2019 version 16.8 and later"
But I didn't test their claim yet.

Can I set the Visual Studio compiler to conform to a specific version of c++?

Can I set the Visual Studio compiler to conform to a specific version of c++ (e.g. C++03 or C++11)? If so, how?
I'm using Visual Studio 2010.
No, you can't. Pretty much the only flag for controlling the language is /Za (don't use Microsoft extensions), and that's so broken that the MS STL isn't even tested with it, and parts might not compile - not to mention the Windows SDK headers.
VS2010 obviously can not be set to C++11 compatibility. (less obviously 2012 can't be either...)
As for C++03 it is fairly compatible, you can find the short list of differences in msdn. Also the options to turn off extensions, though that switch has no practical use.

change C++ version in visual studio

How to check the version of C++ in Visual C++ Express Edition 2010 and change it to C++11?
I've tried to use uniform initialization like std::vector<std::string> v{"Hello" , "World"};, but it doesn't work.
You cannot change the C++ language version used by Visual Studio 2010. It does have partial support for C++11, but since VS 2010 was released before the C++11 standard was finalized, certain features are not exactly in-line with the standard, and furthermore not all features have been implemented.
See this chart for a list of which C++11 features are supported in various major compilers and the versions at which they became available.
Unfortunately, that is not implemented in the compiler yet, not even in VS 2012.
Visual C++ does not support uniform initialization at present time. The most recent compiler CTP release (for Visual Studio 2012, not 2010) has support for it, but that is an alpha-quality product. Moreover, there is no standard library support in there yet, so you still wouldn't be able to use uniform initialization with vector.
(In any case, how would you expect C++2011 to be supported on MSVC++2010?)

Which version of C++ am I using?

Currently I am using C++ in Windows environment. I am using Visual Studio 2008 with Service pack 1.
I never thought about C++ version unless until I came to know about C++11. There appear to be different versions like ANSI standard, C++ 98 Standard etc.
How do I get to know which version of C++ am I using?
If I don't have Visual Studio I know I can use other Compilers like TC to compile my C++ code. In that case how can I get to know which version of C++ the compiler is using.
Are the changes made in consecutive C++ versions about Programming concepts or only in Language design?
It's not as simple as a version check.
Every compiler that supports some C++11 supports a different subset of C++11. No compiler advertises full compliance with C++11 yet, for obvious reasons.
The C++11 specification requires that a predefined macro, __cplusplus be defined which has the value 201103L. However, you cannot rely on this macro alone. Not in real code.
You instead have to rely on compiler-specific macros to tell when compiler and which version of that compiler you're using. Or you can use Boost.Config to help you detect whether specific features are supported.
Visual Studio 2008? You can forget C++11.
Visual Studio 2010 has some C++11 but it's buggy.
Visual Studio 2012 has better C++11 for some features, but others are missing.
Visual Studio 2013 has new support for variadic templates and other features.
But VS is behind other compilers such as gcc in C++11 support.
You can download free express editions for all these versions.