summaryrefslogtreecommitdiffhomepage
path: root/CompilerDriver/cc2/regression-tests/mixed-intro-example-three-loops.cpp2
blob: bfe37f8c32b52097925ab146204bec2e9c564da2 (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
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <span>
#include <memory>

auto print(auto const& thing) -> void { 
    std::cout << ">> " << thing << "\n";
}

auto decorate_and_print(auto& thing) -> void { 
    thing = "[" + thing + "]";
    print(thing);
}

auto main() -> int {
    auto words = std::vector<std::string>
        { "hello", "big", "world" };

    std::span<std::string> view{ words };

    auto i = std::make_unique<int>(0);
    while (*i < view.size()) {
        print( view[*i] );
        ++*i;
    }

    do {
        std::cout << std::setw(4) << "**";
    } while (--*i > 0);

    std::cout << "\n";
    for (auto& word : words) {
        decorate_and_print(word);
    }
}