Learn how to compile c++ 17 program in Linux ubuntu. C++17 features are available in GCC 5 and later. To compile C++17 program , add the command-line parameter -std=c++17
or -std=c++1y or -std=c++1z
to your g++ command.

Let us try to compile below c++ 17 code

/* main.cpp */

#include<iostream>
#include<experimental/any>
using namespace std;

int main()
{
  experimental::fundamentals_v1::any obj = int(5);
  cout << experimental::fundamentals_v1::any_cast<int> (obj);
  cout << endl;
  return 0;
}

how to compile c++ 17 program in Linux ubuntu

#g++ -std=c++17 main.cpp

ISO C++1z standard is still in development , all available features are experimental. Under Ubuntu based OS all headers are lying inside /usr/include/c++/5/experimental/any

how to compile c++ 17 program in Linux ubuntu

Youtube video tutorial

Ref:
https://gcc.gnu.org/projects/cxx-status.html#cxx1z



Related Contents to follow