From ff0507d6db02b9fc43e621d51b73419018bb38c8 Mon Sep 17 00:00:00 2001
From: Bent Bisballe Nyeng <deva@aasimon.org>
Date: Mon, 24 Jul 2023 15:00:59 +0200
Subject: A1: c++20 variation and report.

---
 a1/exercise.tex | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 a1/exercise.tex

(limited to 'a1/exercise.tex')

diff --git a/a1/exercise.tex b/a1/exercise.tex
new file mode 100644
index 0000000..b02f83f
--- /dev/null
+++ b/a1/exercise.tex
@@ -0,0 +1,36 @@
+\title{A1: Tool Chain}
+\input{preamble.tex}
+
+This assignment consists of two small programs; \texttt{hello.cc}
+and \texttt{hello-cpp20.cc}.
+Both use \texttt{import <module>} rather the \texttt{\#include <module>}
+which on my tool-chain (gcc on linux) requires some pre-generation in
+order to work.
+A \texttt{Makefile} is provided which handles all the necessary
+pre-generation as well as the actual compilation of the programs.
+
+\section*{Exercise 1}
+The \texttt{hello.cc} simply prints a \texttt{const char*} literal
+string to the console using the \texttt{std::cout} output stream.
+
+\section*{Exercise 2}
+The \texttt{hello-cpp2.cc} wraps the printing in a templated function,
+utilizing a \texttt{concept} ``Printable'' to make sure that the stream
+operator is implemented on the supplied type for the \texttt{std::cout}
+stream.
+Examples of calling the function is supplied; one using a \texttt{const
+  char*} literal string, one using a \texttt{std::string} literal, one
+using an \texttt{int}, and finally one using a custom type which fails
+compilation because it doesn't provide a stream operator implementaion
+for \texttt{std::ostream}.
+
+Initially I had the argument for the \texttt{printIt} function being
+just a reference, which failed compilation because of the
+\texttt{std::string} litteral being a temporary.
+Adding \texttt{const} fixed the issue.
+
+I originally had the idea to somehow use \texttt{std::format} for the
+second part of the exercise, but since this is not yet supported by my
+compiler I had to change plans.
+
+\end{document}
-- 
cgit v1.2.3

