From 54a45a17f4b29c7517d6092e723152d308e38b2a Mon Sep 17 00:00:00 2001 From: Sandipan Mohanty <s.mohanty@fz-juelich.de> Date: Fri, 5 May 2023 10:24:34 +0200 Subject: [PATCH] Add folder test_your_setup --- test_your_setup/README.md | 30 ++++++++++++++++++++++++++++++ test_your_setup/hello.cc | 6 ++++++ test_your_setup/hello_c++20.cc | 21 +++++++++++++++++++++ test_your_setup/hello_c++20_m.cc | 21 +++++++++++++++++++++ test_your_setup/hello_m.cc | 7 +++++++ 5 files changed, 85 insertions(+) create mode 100644 test_your_setup/README.md create mode 100644 test_your_setup/hello.cc create mode 100644 test_your_setup/hello_c++20.cc create mode 100644 test_your_setup/hello_c++20_m.cc create mode 100644 test_your_setup/hello_m.cc diff --git a/test_your_setup/README.md b/test_your_setup/README.md new file mode 100644 index 0000000..719a06b --- /dev/null +++ b/test_your_setup/README.md @@ -0,0 +1,30 @@ +# Compile: + +## hello.cc +g++ hello.cc +clang++ hello.cc + +## hello_c++20.cc +g++ -std=c++20 hello_c++20.cc +clang++ -std=c++20 -stdlib=libc++ hello_c++20.cc + +## hello_m.cc + +With gcc: +g++ -std=c++20 -fmodules-ts -xc++-system-header iostream +g++ -std=c++20 -fmodules-ts hello_m.cc + +with clang: +clang++ -std=c++20 -stdlib=libc++ -fmodules hello_m.cc + +## hello_c++20_m.cc + +With gcc: +g++ -std=c++20 -fmodules-ts -xc++-system-header concepts +g++ -std=c++20 -fmodules-ts -xc++-system-header iostream +g++ -std=c++20 -fmodules-ts hello_c++20_m.cc + +With clang: +clang++ -std=c++20 -stdlib=libc++ -fmodules hello_c++20_m.cc + + diff --git a/test_your_setup/hello.cc b/test_your_setup/hello.cc new file mode 100644 index 0000000..9c93922 --- /dev/null +++ b/test_your_setup/hello.cc @@ -0,0 +1,6 @@ +#include <iostream> + +auto main() -> int +{ + std::cout << "Hello, world!\n"; +} diff --git a/test_your_setup/hello_c++20.cc b/test_your_setup/hello_c++20.cc new file mode 100644 index 0000000..5aa6763 --- /dev/null +++ b/test_your_setup/hello_c++20.cc @@ -0,0 +1,21 @@ +#include <iostream> +#include <concepts> + +auto message(auto&& x) +{ + std::cout << x << "\n"; +} + +template <class T> +concept is_a_number = std::integral<T> or std::floating_point<T>; + +auto main() -> int +{ + message("Hello, world!"); + auto n = 1234.0; + if constexpr (is_a_number<decltype(n)>) + std::cout << n << " is a number.\n"; + else + std::cout << n << " is not a number!\n"; +} + diff --git a/test_your_setup/hello_c++20_m.cc b/test_your_setup/hello_c++20_m.cc new file mode 100644 index 0000000..acbf1f6 --- /dev/null +++ b/test_your_setup/hello_c++20_m.cc @@ -0,0 +1,21 @@ +import <iostream>; +import <concepts>; + +auto message(auto&& x) +{ + std::cout << x << "\n"; +} + +template <class T> +concept is_a_number = std::integral<T> or std::floating_point<T>; + +auto main() -> int +{ + message("Hello, world!"); + auto n = 1234.0; + if constexpr (is_a_number<decltype(n)>) + std::cout << n << " is a number.\n"; + else + std::cout << n << " is not a number!\n"; +} + diff --git a/test_your_setup/hello_m.cc b/test_your_setup/hello_m.cc new file mode 100644 index 0000000..f743015 --- /dev/null +++ b/test_your_setup/hello_m.cc @@ -0,0 +1,7 @@ +import <iostream>; + +auto main() -> int +{ + std::cout << "Hello, world!\n"; +} + -- GitLab