From 13dfca457bb7d594e0c67c67466615ad2ddc3c73 Mon Sep 17 00:00:00 2001
From: Sanjeev <thedevelopersanjeev@gmail.com>
Date: Thu, 3 Jun 2021 22:56:47 +0530
Subject: [PATCH 1/6] Update README.md

---
 README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index c6ff2b3..f03a03f 100644
--- a/README.md
+++ b/README.md
@@ -63,4 +63,50 @@ deb(xx); // prints "xx = 3"
 deb(xx, yy, xxyy); // prints "xx, yy, xxyy = 3, 10, 103"
 ```
 
- 
+## Generic Reader and Writer for multiple variables and containers
+```cpp
+template <typename... T>
+void read(T &...args) {
+    ((cin >> args), ...);
+}
+
+template <typename... T>
+void write(T &&...args) {
+    ((cout << args), ...);
+}
+
+template <typename T>
+void readContainer(T &t) {
+    for (auto &e : t) {
+        read(e);
+    }
+}
+
+template <typename T>
+void writeContainer(T &t) {
+    for (const auto &e : t) {
+        write(e, " ");
+    }
+    write("\n");
+}
+```
+## Usage
+```cpp
+  // Question: read three space seprated integers and print them in different lines.
+	int x, y, z;
+	read(x, y, z);
+	write(x, "\n", y, "\n", z, "\n");
+	
+  // even works with variable data types :)
+	int n;
+	string s;
+	read(n, s);
+	write(s, " has length ", n, "\n");
+	
+  // Question: read an array of `N` integers and print it to the output console.
+	int N;
+	read(N);
+	vector<int> arr(N);
+	readContainer(arr);
+	writeContainer(arr);
+```

From d9e243272107dde0ac79b035b4867d2c11024dc2 Mon Sep 17 00:00:00 2001
From: Sanjeev <thedevelopersanjeev@gmail.com>
Date: Fri, 4 Jun 2021 11:27:27 +0530
Subject: [PATCH 2/6] Update README.md

---
 README.md | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index f03a03f..afc1bbd 100644
--- a/README.md
+++ b/README.md
@@ -71,8 +71,8 @@ void read(T &...args) {
 }
 
 template <typename... T>
-void write(T &&...args) {
-    ((cout << args), ...);
+void write(string delimiter, T &&...args) {
+    ((cout << args << delimiter), ...);
 }
 
 template <typename T>
@@ -83,30 +83,41 @@ void readContainer(T &t) {
 }
 
 template <typename T>
-void writeContainer(T &t) {
+void writeContainer(T &t, string delimiter = " ") {
     for (const auto &e : t) {
-        write(e, " ");
+        write(delimiter, e);
     }
     write("\n");
 }
 ```
 ## Usage
 ```cpp
-  // Question: read three space seprated integers and print them in different lines.
+// Question: read three space seprated integers and print them in different lines.
 	int x, y, z;
 	read(x, y, z);
-	write(x, "\n", y, "\n", z, "\n");
+	write("\n", x, y, z);
 	
-  // even works with variable data types :)
+// even works with variable data types :)
 	int n;
 	string s;
 	read(n, s);
-	write(s, " has length ", n, "\n");
+	write(" ", s, "has length", n, "\n");
 	
-  // Question: read an array of `N` integers and print it to the output console.
+// Question: read an array of `N` integers and print it to the output console.
 	int N;
 	read(N);
 	vector<int> arr(N);
 	readContainer(arr);
-	writeContainer(arr);
+	writeContainer(arr); // output: arr[0] arr[1] arr[2] ... arr[N - 1]
+	writeContainer(arr, "\n);
+	/**
+	* output:
+	* arr[0]
+	* arr[1]
+	* arr[2]
+	* ...
+	* ...
+	* ...
+	* arr[N - 1]
+	*/
 ```

From 8067cae32f455c45db06f82ac6cfa071037bf927 Mon Sep 17 00:00:00 2001
From: Sanjeev <thedevelopersanjeev@gmail.com>
Date: Fri, 4 Jun 2021 11:40:24 +0530
Subject: [PATCH 3/6] Update README.md

---
 README.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index afc1bbd..d442ade 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@ If you like Rachit's work, you can follow at -
   - [How debug macros work?](#how-debug-macros-work)
   - [The Problem with this macro - its not scalable](#the-problem-with-this-macro---its-not-scalable)
   - [Solution using a powerful macro](#solution-using-a-powerful-macro)
+  - [Generic Reader and Writer for multiple variables and containers](#generic-reader-and-writer-for-multiple-variables-and-containers)
 
 ## JavaScript like Destructuring using Structured Binding in C++
 ```cpp
@@ -90,7 +91,7 @@ void writeContainer(T &t, string delimiter = " ") {
     write("\n");
 }
 ```
-## Usage
+### Usage
 ```cpp
 // Question: read three space seprated integers and print them in different lines.
 	int x, y, z;

From 07715d7dab591933d561f614fedeea3aa0480775 Mon Sep 17 00:00:00 2001
From: Sanjeev <thedevelopersanjeev@gmail.com>
Date: Fri, 4 Jun 2021 11:50:22 +0530
Subject: [PATCH 4/6] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 99ccedf..98f1dbd 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ If you like Rachit's work, you can follow at -
   - [How debug macros work?](#how-debug-macros-work)
   - [The Problem with this macro - its not scalable](#the-problem-with-this-macro---its-not-scalable)
   - [Solution using a powerful macro](#solution-using-a-powerful-macro)
-  - [Generic Reader and Writer for multiple variables and containers](#generic-reader-and-writer-for-multiple-variables-and-containers)
+- [Generic Reader and Writer for multiple variables and containers](#generic-reader-and-writer-for-multiple-variables-and-containers)
 - [Decorators in C++ and Multiple Parameters](#decorators-in-c-and-multiple-parameters)
   - [Live Demo on YouTube](#live-demo-on-youtube)
   - [Printing as many variables in one line](#printing-as-many-variables-in-one-line)

From aa6697dba172a4e045385bf0aca0e53da0eaa34c Mon Sep 17 00:00:00 2001
From: Sanjeev <thedevelopersanjeev@gmail.com>
Date: Sat, 5 Jun 2021 21:32:04 +0530
Subject: [PATCH 5/6] Fixed a typo

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 98f1dbd..8f625aa 100644
--- a/README.md
+++ b/README.md
@@ -133,7 +133,7 @@ void writeContainer(T &t, string delimiter = " ") {
 	vector<int> arr(N);
 	readContainer(arr);
 	writeContainer(arr); // output: arr[0] arr[1] arr[2] ... arr[N - 1]
-	writeContainer(arr, "\n);
+	writeContainer(arr, "\n");
 	/**
 	* output:
 	* arr[0]

From f2b9762fb8bf756707cf411e98d129eadfe4b253 Mon Sep 17 00:00:00 2001
From: Sanjeev <thedevelopersanjeev@gmail.com>
Date: Sat, 5 Jun 2021 21:46:39 +0530
Subject: [PATCH 6/6] Update writeContainer signature

---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 8f625aa..bbd7003 100644
--- a/README.md
+++ b/README.md
@@ -107,7 +107,7 @@ void readContainer(T &t) {
 }
 
 template <typename T>
-void writeContainer(T &t, string delimiter = " ") {
+void writeContainer(string delimiter, T &t) {
     for (const auto &e : t) {
         write(delimiter, e);
     }
@@ -132,8 +132,8 @@ void writeContainer(T &t, string delimiter = " ") {
 	read(N);
 	vector<int> arr(N);
 	readContainer(arr);
-	writeContainer(arr); // output: arr[0] arr[1] arr[2] ... arr[N - 1]
-	writeContainer(arr, "\n");
+	writeContainer(" ", arr); // output: arr[0] arr[1] arr[2] ... arr[N - 1]
+	writeContainer("\n", arr);
 	/**
 	* output:
 	* arr[0]
