aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsample/strlist.cpp
blob: 5840a0516acc84a5d9b8abe56c32a83b3682e59a (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "strlist.h"

#include <algorithm>

bool StrList::operator==(const std::list<Str> &other) const
{
    return size() == other.size()
        && std::equal(begin(), end(), other.begin());
}

Str StrList::join(const Str &sep) const
{
    Str result;
    const auto i1 = begin();
    const auto i2 = end();
    for (auto it = i1; i1 != i2; ++it) {
        if (it != i1)
            result.append(sep);
        result.append(*it);
    }
    return result;
}