Reputation: 63
The code I am writing is throwing this error:
'optional': is not a member of 'std'
I understand that the file <optional>
is located in MSVC/tools and this external dependencies section is usually populated by Intellisense, but the file appears not to be included even though I confirmed that the file does indeed exist and I have #include <optional>
.
What is the best way to close the gap here?
Is there a way to tell Visual Studio to include all the MSVC tools?
Code snippet from header:
#pragma once
#include Examples.h
#include <optional>
#include <vector>
namespace Samples
Code snippet from cpp:
#include 'Examples.h'
std::optional<Samples::Matrix> Samples::TestFunction()
Upvotes: 4
Views: 10220
Reputation: 10936
You must have your C++ Language Standard option in Project Settings set to C++17 or later:
Configuration Properties > General > C++ Language Standard
ISO C++17 Standard (/std:c++17)
or Preview Latest (/std:latest)
ISO C++20 Standard (/std:c++20)
is also an option.OK
Upvotes: 12