diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-01-17 16:23:24 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-01-17 16:23:24 +0100 |
| commit | 0b43d984905f07c59e3236d98d4e27409aba3cda (patch) | |
| tree | ef707db657a9a3ff0da21ee06ac8df65f9a561a9 /templates/println.cpp | |
| parent | d0f3f64bb42ea8194c20f0eadd35821cab346143 (diff) | |
| download | taming-cpp-0b43d984905f07c59e3236d98d4e27409aba3cda.tar.gz taming-cpp-0b43d984905f07c59e3236d98d4e27409aba3cda.zip | |
More stuff with templates
Diffstat (limited to '')
| -rw-r--r-- | templates/println.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/templates/println.cpp b/templates/println.cpp new file mode 100644 index 0000000..62f27ac --- /dev/null +++ b/templates/println.cpp | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | #include <iostream> | ||
| 2 | |||
| 3 | template<auto X> void println() { std::cout << X << std::endl; } | ||
| 4 | |||
| 5 | int main() { | ||
| 6 | println<1.23>(); | ||
| 7 | println<42>(); | ||
| 8 | |||
| 9 | // The following attempts to print a string do not work | ||
| 10 | // uncomment to see why | ||
| 11 | // 1. | ||
| 12 | // println<"Hello!">(); | ||
| 13 | // 2. | ||
| 14 | // constexpr std::string_view hello = "Hello!"; | ||
| 15 | // println<hello>(); | ||
| 16 | |||
| 17 | return 0; | ||
| 18 | } | ||
