summaryrefslogtreecommitdiff
path: root/tests/unit/unittest/gtest-std-printing.h
blob: af62ddfb1ee31ad1bf282e828db879533687299e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <ostream>
#include <vector>

namespace std {
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &vector)
{
    out << "[";

    for (auto current = vector.begin(); current != vector.end(); ++current) {
        out << *current;

        if (std::next(current) != vector.end())
            out << ", ";
    }

    out << "]";

    return out;
}

} // namespace std