a_unique_name 286 Reputation points

Hi Folks:

Developing with Visual Studio, updated today to version 17.4.4.

I'm starting the Vulkan tutorial and I'm stuck at:

I can't get Code Block to work for me, so here's the code:

struct QueueFamilyIndices {
std::optional<uint32_t> graphicsFamily;

bool isComplete() {  
    return graphicsFamily.has_value();  


The errors are on the std::optional statement.
error C2039: 'optional': is not a member of 'std'
error C7568: argument list missing after assumed function template 'optional'

Here's Project Properties -> C++ -> Language:


I've tried different C++ Language Standard, Conformance mode and even C Language Standard, with no effect. shows a c++17 compliant compiler should be able to handle std::optional.

What am I doing wrong?


A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
2,632 questions
No comments
{count} votes

Accepted answer
  1. YujianYao-MSFT 3,521 Reputation points Microsoft Employee

    Hi @a_unique_name

    After testing, std::optional can be used in VS.

    I suggest you to add <optional> header file and set c++ language standard.

    enter image description here enter image description here

    Best regards,


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

1 additional answer

Sort by: Most helpful
  1. a_unique_name 286 Reputation points

    The Forum software is sticking part of the code inside a code block, but not all of it.

    I already wasted an hour trying to put it inside of a code block, erased everything and recomposed the question, without a code block.

    Everything I try to do just makes it more unreadable.

    The code is the struct, the error is the std::optional, and the code block is around a function in the struct that doesn't even need to be there, but not work another half an hour trying to fix.

    I'm not a fan of the forum software. Looks like something Microsoft would build.

    Does anybody else prefer the forum software we had with MSDN?

    No comments