Basic command line REPL calculator I'm pretty confident in this code but I want to be sure I haven't missed anything to do with optimization or error handling. The program takes input in the form of {number} {operator} {number} and prints the result. If the input is invalid it prints nothing.

Example input: 1.0 + 2.0
Output: 3

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;stdexcept&gt;
#include &lt;regex&gt;

double calculate(const double a, const char op, const double b)
{
    switch (op)
    {
        case '+':
            return a + b;
        case '-':
            return a - b;
        case '*':
            return a * b;
        case '/':
            if (b == 0.0)
                throw std::invalid_argument {"Divide by zero"};
            return a / b;
        default:
            throw std::invalid_argument {{op}};
    }
}

int main()
{
    const std::regex valid_input {
        "([0-9]*\\.?[0-9]*) ([\\+\\-\\*\\/]) ([0-9]*\\.?[0-9]*)"};

    std::string line;
    std::smatch terms;

    double a;
    double b;
    char op;

    while (std::getline(std::cin, line))
    {
        if (!std::regex_match(line, terms, valid_input))
            continue;

        a = std::stod(terms[1]);
        b = std::stod(terms[3]);
        op = terms[2].str().front();

        std::cout &lt;&lt; calculate(a, op, b) &lt;&lt; '\n';
    }
}
What happens if I enter only + surrounded by spaces?
The program should not abort if I enter 0 / 0, but continue with the next line.
I'd like to omit the spaces around the operator.
In the regular expression, the operator part can be written as [+\\-*/].