diff options
author | Adrian Kummerlaender | 2018-02-02 21:22:39 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2018-02-02 21:23:37 +0100 |
commit | f58e836911d5e59ba69e70d459d844ba72523b72 (patch) | |
tree | db4aad1b667e7f8dc9d1d54e0c386c14914621df /src | |
parent | 0985a623e4cbd14da77fddf1bb1a9ca3384b28ea (diff) | |
download | SimpleParser-f58e836911d5e59ba69e70d459d844ba72523b72.tar SimpleParser-f58e836911d5e59ba69e70d459d844ba72523b72.tar.gz SimpleParser-f58e836911d5e59ba69e70d459d844ba72523b72.tar.bz2 SimpleParser-f58e836911d5e59ba69e70d459d844ba72523b72.tar.lz SimpleParser-f58e836911d5e59ba69e70d459d844ba72523b72.tar.xz SimpleParser-f58e836911d5e59ba69e70d459d844ba72523b72.tar.zst SimpleParser-f58e836911d5e59ba69e70d459d844ba72523b72.zip |
Replace boost::optional with std::optional
Diffstat (limited to 'src')
-rw-r--r-- | src/tree.cc | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/tree.cc b/src/tree.cc index 8e29255..23294da 100644 --- a/src/tree.cc +++ b/src/tree.cc @@ -1,8 +1,7 @@ #include "tree.h" #include "exceptions.h" -#include <boost/optional.hpp> - +#include <optional> #include <sstream> #include <limits> #include <stack> @@ -12,18 +11,18 @@ namespace { using SimpleParser::Node; - boost::optional<Node*> top(const std::stack<Node*> stack) { + std::optional<Node*> top(const std::stack<Node*> stack) { if ( !stack.empty() ) { - return boost::make_optional<Node*>( + return std::make_optional<Node*>( stack.top() ); } else { - return boost::optional<Node*>(); + return std::optional<Node*>(); } } - boost::optional<Node*> pop(std::stack<Node*>& stack) { - if ( boost::optional<Node*> node{ top(stack) } ) { + std::optional<Node*> pop(std::stack<Node*>& stack) { + if ( std::optional<Node*> node{ top(stack) } ) { stack.pop(); return node; @@ -130,7 +129,7 @@ Node* Tree::buildTree(const std::string& term) { this->addNode<OperatorNode>(elementToken) ); } else { - if ( boost::optional<Node*> lastNode{ top(operators) } ) { + if ( std::optional<Node*> lastNode{ top(operators) } ) { OperatorNode*const lastOperator{ static_cast<OperatorNode*const>(*lastNode) }; @@ -141,9 +140,9 @@ Node* Tree::buildTree(const std::string& term) { this->addNode<OperatorNode>(elementToken) ); } else { - boost::optional<Node*> currentOperator{ pop(operators) }; - boost::optional<Node*> rightChild { pop(operands) }; - boost::optional<Node*> leftChild { pop(operands) }; + std::optional<Node*> currentOperator{ pop(operators) }; + std::optional<Node*> rightChild { pop(operands) }; + std::optional<Node*> leftChild { pop(operands) }; if ( currentOperator && rightChild && leftChild ) { static_cast<OperatorNode*const>( @@ -204,9 +203,9 @@ Node* Tree::buildTree(const std::string& term) { } while ( !operators.empty() ) { - boost::optional<Node*> currentOperator{ pop(operators) }; - boost::optional<Node*> rightChild { pop(operands) }; - boost::optional<Node*> leftChild { pop(operands) }; + std::optional<Node*> currentOperator{ pop(operators) }; + std::optional<Node*> rightChild { pop(operands) }; + std::optional<Node*> leftChild { pop(operands) }; if ( currentOperator && rightChild && leftChild ) { static_cast<OperatorNode*const>( @@ -222,7 +221,7 @@ Node* Tree::buildTree(const std::string& term) { } } - if ( boost::optional<Node*> rootNode{ pop(operands) } ) { + if ( std::optional<Node*> rootNode{ pop(operands) } ) { return *rootNode; } else { throw operator_exception(); |