O'Reilly logo

C++17 STL Cookbook by Jacek Galowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

In this section, we will read a mathematical expression in RPN from the standard input, and then feed it into a function that evaluates it. In the end, we print the numeric result back to the user.

  1. We will use a lot of helpers from the STL, so there are a few includes:
      #include <iostream>      #include <stack>      #include <iterator>      #include <map>      #include <sstream>      #include <cassert>      #include <vector>      #include <stdexcept>      #include <cmath>
  1. And we do also declare that we are using namespace std in order to spare us some typing.
      using namespace std;
  1. Then, we immediately start implementing our RPN parser. It will accept an iterator pair, which denotes the beginning and end of a mathematical expression in string form, which will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required