aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libminimal/spanuser.cpp
blob: fea9cd68e5fccd690db09399e2acee8d1a474658 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "spanuser.h"

#include <numeric>

SpanUser::SpanUser() = default;

bool SpanUser::enabled()
{
#if __cplusplus >= 202002L
    return true;
#else
    return false;
#endif
}

#if __cplusplus >= 202002L
IntSpan3 SpanUser::getIntSpan3()
{
    static int iv[] = {1, 2, 3};
    return IntSpan3(iv);
}

IntSpan SpanUser::getIntSpan()
{
    static int iv[] = {1, 2, 3};
    return IntSpan(iv);
}

ConstIntSpan3 SpanUser::getConstIntSpan3()
{
    static const int civ[] = {1, 2, 3};
    return ConstIntSpan3(civ);
}

IntSpan3 SpanUser::getIntSpan3_OpaqueContainer()
{
    static int iv[] = {1, 2, 3};
    return IntSpan3(iv);
}

int SpanUser::sumIntSpan3(IntSpan3 isp3)
{
     return std::accumulate(isp3.begin(), isp3.end(), 0);
}

int SpanUser::sumIntSpan(IntSpan isp)
{
     return std::accumulate(isp.begin(), isp.end(), 0);
}

int SpanUser::sumConstIntSpan3(ConstIntSpan3 ispc3)
{
    return std::accumulate(ispc3.begin(), ispc3.end(), 0);
}
#endif // C++ 20