Project Euler #3 In C++
You can improve the performance of the inner divisibility test by using std::div to do the division and modulo operations in one step. The following should work:

    for (;;) {
        auto r = std::div(n, p);
        if (r.rem != 0) {
            break;
        }
        n = r.quot;
        base_factors.push_back(p);
    }


The return value of std::div is a type such as std::lldiv_t (the exact return type ultimately depends on the template type parameter T).