diff --git a/test_your_setup/README.md b/test_your_setup/README.md new file mode 100644 index 0000000000000000000000000000000000000000..719a06b9d60804e2a1f276139469279477682227 --- /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 0000000000000000000000000000000000000000..da9e571df49e6724b13114a924b7860a0c26b538 --- /dev/null +++ b/test_your_setup/hello.cc @@ -0,0 +1,7 @@ +#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 0000000000000000000000000000000000000000..5aa6763727927617c1d9dc9808dbff4998c85483 --- /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 0000000000000000000000000000000000000000..acbf1f668f10ede246786c93ff71196481b7e515 --- /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 0000000000000000000000000000000000000000..f743015337ce7b049038e5ba97b0fca1e08ae90d --- /dev/null +++ b/test_your_setup/hello_m.cc @@ -0,0 +1,7 @@ +import <iostream>; + +auto main() -> int +{ + std::cout << "Hello, world!\n"; +} +