GGBOI250
GGBOI250

Reputation: 31

Visual C++ error, namespace "std" has no member "any"

Here is the code preview in vs 2019

Upvotes: 0

Views: 5399

Answers (2)

Ken_sf
Ken_sf

Reputation: 119

I had to add an include to <any> to get my program to compile. My includes look like this:

#include <iostream>
#include <any>

I also was able to confirm I was using the c++ 17 compiler by doing this:

   std::cout << __cplusplus << std::endl;
    /*
see this on SO <https://stackoverflow.com/questions/2324658/how-to-determine-the-version-of-the-c-standard-used-by-the-compiler>
C++ pre-C++98: __cplusplus is 1.
C++98: __cplusplus is 199711L.
C++98 + TR1: This reads as C++98 and there is no way to check that I know of.
C++11: __cplusplus is 201103L.
C++14: __cplusplus is 201402L.
C++17: __cplusplus is 201703L.
C++20: __cplusplus is 202002L.
    */

Upvotes: 1

Max Drie&#223;en
Max Drie&#223;en

Reputation: 99

std::any and std::any_cast were added in c++17, please make sure that you are compiling with the correct version.

Upvotes: 2

Related Questions