From f14db076fe96a62a1f7b0f76f7fd851714147162 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sun, 29 Dec 2019 19:15:26 +0100 Subject: doc: restructure documentation --- examples/src/basic_usage.cpp | 39 ++++++++++++++++++++++++++++++++ examples/src/basic_usage_with_read.cpp | 39 ++++++++++++++++++++++++++++++++ examples/src/basic_usage_with_show.cpp | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 examples/src/basic_usage.cpp create mode 100644 examples/src/basic_usage_with_read.cpp create mode 100644 examples/src/basic_usage_with_show.cpp (limited to 'examples') diff --git a/examples/src/basic_usage.cpp b/examples/src/basic_usage.cpp new file mode 100644 index 0000000..a2a50cd --- /dev/null +++ b/examples/src/basic_usage.cpp @@ -0,0 +1,39 @@ +#include + +#include + +using Width = nt::new_type; +using Height = nt::new_type; +using Area = nt::new_type; + +struct Rectangle +{ + constexpr Rectangle(Width w, Height h) + : width{w} + , height{h} + { + } + + auto constexpr area() const noexcept -> Area + { + return {width.decay() * height.decay()}; + } + +private: + Width width; + Height height; +}; + +int main() +{ + auto w{0u}, h{0u}; + + std::cin >> w >> h; + + auto width = Width{w}; + auto height = Height{h}; + + auto rect = Rectangle{width, height}; + + std::cout << rect.area().decay() << '\n'; +} \ No newline at end of file diff --git a/examples/src/basic_usage_with_read.cpp b/examples/src/basic_usage_with_read.cpp new file mode 100644 index 0000000..87fcc1a --- /dev/null +++ b/examples/src/basic_usage_with_read.cpp @@ -0,0 +1,39 @@ +#include +#include +#include + +#include + +using Width = nt::new_type; +using Height = nt::new_type; +using Area = nt::new_type; + +struct Rectangle +{ + constexpr Rectangle(Width w, Height h) + : width{w} + , height{h} + { + } + + auto constexpr area() const noexcept -> Area + { + return {width.decay() * height.decay()}; + } + +private: + Width width; + Height height; +}; + +int main() +{ + auto width = Width{}; + auto height = Height{}; + + std::cin >> width >> height; + + auto rect = Rectangle{width, height}; + + std::cout << rect.area() << '\n'; +} \ No newline at end of file diff --git a/examples/src/basic_usage_with_show.cpp b/examples/src/basic_usage_with_show.cpp new file mode 100644 index 0000000..1a83968 --- /dev/null +++ b/examples/src/basic_usage_with_show.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +#include + +using Width = nt::new_type; +using Height = nt::new_type; +using Area = nt::new_type; + +struct Rectangle +{ + constexpr Rectangle(Width w, Height h) + : width{w} + , height{h} + { + } + + auto constexpr area() const noexcept -> Area + { + return {width.decay() * height.decay()}; + } + +private: + Width width; + Height height; +}; + +int main() +{ + auto w{0u}, h{0u}; + + std::cin >> w >> h; + + auto width = Width{w}; + auto height = Height{h}; + + auto rect = Rectangle{width, height}; + + std::cout << rect.area() << '\n'; +} \ No newline at end of file -- cgit v1.2.3