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

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

Related

Visual studio 2013 to compile strict c++11

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.

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.

Visual Studio 2010: chrono header file missing

I just installed Visual Studio 2010 Ultimate and wanted to write a simple program in C++.
But it seems like VS doesn't find the header file "chrono".
I tought installing SP1 would help, but it didn't.
There also some other header files like "thread" missing.
Does anyone know where I can get these missing files?
VS2010 only has partial C++11 support. You need VS2012+.
As an addition to Mark's answer, no Visual Studio version fully supports C++11 now. Here is the complete table of features: C++11 Features (Modern C++)
You can also read here for getting more information BOOST
Chrono is a standard template library that has been introduced in Visual Studio 2012.
Chrono is used to manipulate time durations and time instants.
Visual Studio 2010 or even with SP1 will not support Chrono.

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.

Is it possible to compile ffmpeg in visual studio 2010?

Is it possible to compile the sourcecode from ffmpeg in visual studio 2010? Is it difficult?
Just looking for some advice (and instructions) if possible. :-)
Cheers,
Pete
Apparently someone at Google has written a C99 to C89 "downconverter" in part to get ffmpeg to compile with Visual Studio:
http://blogs.gnome.org/rbultje/2012/09/27/microsoft-visual-studio-support-in-ffmpeg-and-libav/
The tool they wrote is currently only in source code form. Although that tool is written in C, it uses some compiler specific includes, specific to the Clang compiler, so you currently need clang to compile it. I had to get all the pieces to Clang (which relies on llvm) and compile with VS2010. OK, got that figured out, so now I have the two tools compiled: c99wrap.exe and c99conv.exe.
The blog does not mention two important things that are mentioned here:
http://libav.org/platform.html#Microsoft-Visual-C_002b_002b
First, you have to ensure the link.exe you use is the Visual C linker and not the mingw linker. Also, the msvc toolchain under msys does not yet support shared DLL builds, it only supports static lib builds at this time, so --enabled-shared fails to link.
It is not possible because ffmpeg makes extensive use of C99 features (with good reason), and MSVC doesn't support nearly enough nook and crannies of the standard.
You can however, use the C library built by MinGW for use with Visual Studio projects. See the following links for all the information you need:
Information about building/using the library on Windows with Visual Studio: http://ffmpeg.arrozcru.org/wiki/index.php?title=Main_Page
Downloads: http://ffmpeg.arrozcru.org/autobuilds/
Of course it is possible
To use FFmpeg SVN libraries with your Microsoft Visual C++ project,
you must first make sure your Microsoft Visual C++ build system has
the inttypes.h and stdint.h include files.
How do I know if I have those files? Well... unless you already did
this and know you have that file, you don't have it. MSVC++ does not
adhere to the C99 standard, where that file is specified, so you're on
your own here.
Alexander Chemeris was nice enough to make such files for Microsoft
Visual C++, so they can be found here
Download latest archive from link above and unpack it to the folder to
which you installed FFmpeg's include files. The default path is
/usr/local/include, which is, in this guide for Windows,
C:\msys\local\include.
Inttypes C99
Visual Studio 2013 provides the support for C99 which was missing earlier. With this ffmpeg can now be built using Visual Studio 2013. You can read more about the new language/libraries features here.
Also, try out Visual Studio 2013 RC here.
According to the documentation it is not possible.