Skip to content

Commit 48625b9

Browse files
authored
ci: Upgrade C++ compiler on Ubuntu Focal to support C++20 compilation. (#22)
1 parent 8ab8a1e commit 48625b9

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,23 @@ jobs:
4343
name: "Install coreutils (for md5sum)"
4444
run: "brew install coreutils"
4545

46+
- if: "matrix.os == 'ubuntu-20.04'"
47+
name: "Install gcc-10 (for c++20)"
48+
run: |-
49+
sudo apt-get update
50+
sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
51+
g++-10 \
52+
gcc-10
53+
sudo ln --symbolic --force /usr/bin/gcc-10 /usr/bin/cc
54+
sudo ln --symbolic --force /usr/bin/g++-10 /usr/bin/c++
55+
sudo ln --symbolic --force /usr/bin/cpp-10 /usr/bin/cpp
56+
4657
- name: "Log tool versions"
4758
run: |-
48-
md5sum --version
49-
python --version
50-
tar --version
51-
task --version
59+
command -v md5sum
60+
command -v python
61+
command -v tar
62+
command -v task
5263
5364
# TODO: Change the task to run all unittests once any unittest is added. Until then we check
5465
# that building the project succeeds.

src/main.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
#include <concepts>
12
#include <iostream>
23
#include <ystdlib/testlib/hello.hpp>
34

5+
namespace {
6+
template <typename T>
7+
requires std::integral<T>
8+
[[nodiscard]] auto square(T x) -> T {
9+
return x * x;
10+
}
11+
}; // namespace
12+
413
[[nodiscard]] auto main() -> int {
5-
std::cout << ystdlib::testlib::hello() << '\n';
14+
std::cout << square(ystdlib::testlib::hello().size()) << '\n';
615
return 0;
716
}

0 commit comments

Comments
 (0)