feat: add challenge code

This commit is contained in:
jfmcarreira committed 2024-03-13 01:55:14 +00:00
commit 5634d1bb39
22 files changed
+925

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#ifndef CALCULATOR_CHALLENGE_OPERAND_HPP
#define CALCULATOR_CHALLENGE_OPERAND_HPP
#include <functional>
#include <string>
#include <variant>
template<typename T>
using BinaryOperatorType = std::function<T(T, T)>;
using Operator = BinaryOperatorType<double>;
class IntegerOperand
{
public:
explicit IntegerOperand(double value) noexcept : _value{value} {}
auto get() const noexcept -> double { return _value; };
private:
double _value{0};
};
class VariableOperand
{
public:
explicit VariableOperand(std::string name) noexcept : _name{std::move(name)} {}
auto get() const noexcept -> std::string { return _name; };
private:
std::string _name;
};
using Operand = std::variant<IntegerOperand, VariableOperand>;
#endif