Skip to content
Snippets Groups Projects
Commit 6d0045d6 authored by Sandipan Mohanty's avatar Sandipan Mohanty
Browse files

Add examples to test set up

parent f7e70116
No related branches found
No related tags found
No related merge requests found
# 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
#include <iostream>
auto main() -> int
{
std::cout << "Hello, world!\n";
}
#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";
}
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";
}
import <iostream>;
auto main() -> int
{
std::cout << "Hello, world!\n";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment