Given two vectors of ints, determine whether one vector is a prefix of the other
Embrace auto. Not only is it shorter, but avoids embarrassing bugs in choosing the wrong type.
decltype() is generally much more cumbersome.

Embrace abstraction. Solving the task itself deserves its own re-usable function. Good naming even reduces the need for comments, which can get out-of-sync.

Embrace the standard library. It is well-tested and well-known. Reinventing wheels for no reason is a poor use of time.

You refrained from using std::endl until your last line. No need to use it at all, ending the program flushed the output too.

std::boolalpha is the tool of choice for streaming a bool as &quot;true&quot; or &quot;false&quot;.

Combine std::copy() and std::ostream_iterator for streaming an iterator-range.


#include &lt;vector&gt;
#include &lt;iostream&gt;
#include &lt;algorithm&gt;

template &lt;class T, class U&gt;
constexpr bool is_shorter_prefix(const T&amp; a, const U&amp; b) noexcept {
    const auto n = std::min(std::size(a), std::size(b));
    return std::equal(std::begin(a), std::begin(a) + n, std::begin(b));
}

template &lt;class T&gt;
void output_range(std::ostream&amp; os, const T&amp; t) {
    using U = decltype(*std::begin(t));
    std::copy(std::begin(t), std::end(t), std::ostream_iterator&lt;U&gt;(os, &quot;, &quot;));
}

int main() {
    const std::vector&lt;int&gt; a = { 0, 1, 1, 2 };
    const std::vector&lt;int&gt; b = { 0, 1, 1, 2, 3, 5, 8 };

    const auto is_prefix = is_shorter_prefix(a, b);

    std::cout &lt;&lt; &quot;small vector:\n&quot;;
    output_range(std::cout, a.size() &lt;= b.size() ? a : b);
    std::cout &lt;&lt; &quot;\nIs prefix of big vector:\n&quot;;
    output_range(std::cout, a.size() &gt; b.size() ? a : b);
    std::cout &lt;&lt; &quot;\n&quot; &lt;&lt; std::boolalpha &lt;&lt; is_prefix &lt;&lt; &quot;\n&quot;;
}