Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

namespace std:: does not contain optional

i am doing the Vulkan Tutorial https://vulkan-tutorial.com/

#define GLFW_INCLUE_VULKAN
#include<GLFW/glfw3.h>
#include<optional>

struct s {
    std::optional<uint32_t> num;//Intellisense Error
};

int main() {
    return 5;
}

I started with an empty project and added includes and libraries; I can compile and run without including std::optional.

When i use std::optional I get c2039 "optional is not a member of std"

I am running Windows 10, and VisualStudio 2019

What is going on here ?

thx.

like image 852
DuckPuppy Avatar asked Jun 14 '20 08:06

DuckPuppy


1 Answers

std::optional requires C++17.

Live on Godbolt.

you can use /std:c++17 flag on MSVC and -std=c++17 on gcc/clang.

like image 154
Oblivion Avatar answered Sep 30 '22 07:09

Oblivion