From 54ad9358758df536710bb54e4f2d606eb7795436 Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Tue, 16 Jul 2019 09:26:31 +0200 Subject: [PATCH] see #2: code updates --- code/1/1.1.c.and.cpp | 1 + code/1/Makefile | 1 + code/1/foo.c | 1 + code/1/foo.h | 1 + code/10/Makefile | 9 ++++++++- code/2/2.01.nullptr.cpp | 1 + code/2/2.02.constexpr.cpp | 1 + code/2/2.03.if.switch.cpp | 4 ++-- code/2/2.04.initializer.list.cpp | 1 + code/2/2.05.structured.binding.cpp | 1 + code/2/2.06.auto.cpp | 1 + code/2/2.07.decltype.cpp | 1 + code/2/2.08.tail.return.type.cpp | 1 + code/2/2.09.decltype.auto.cpp | 1 + code/2/2.10.if.constexpr.cpp | 1 + code/2/2.11.for.loop.cpp | 1 + code/2/2.12.external.template.cpp | 1 + code/2/2.13.alias.template.cpp | 1 + code/2/2.14.default.template.param.cpp | 1 + code/2/2.15.variadic.template.param.cpp | 1 + code/2/2.16.fold.expression.cpp | 1 + code/2/2.18.non.type.template.auto.cpp | 1 + code/2/Makefile | 7 +++++++ code/2/todo/2.7.cpp | 1 + code/2/todo/2.8.cpp | 1 + code/3/3.1.cpp | 1 + code/3/3.2.cpp | 1 + code/3/3.3.cpp | 1 + code/3/3.4.cpp | 1 + code/3/3.5.cpp | 1 + code/3/3.6.cpp | 1 + code/4/4.1.cpp | 1 + code/4/4.2.cpp | 1 + code/4/4.3.cpp | 1 + code/7/7.1.cpp | 1 + code/7/7.2.cpp | 1 + code/9/9.1.noexcept.cpp | 1 + code/9/9.2.literals.cpp | 1 + code/9/Makefile | 7 +++++++ exercises/2/fold.expresion.cpp | 1 + exercises/2/structured.binding.cpp | 1 + 41 files changed, 61 insertions(+), 3 deletions(-) diff --git a/code/1/1.1.c.and.cpp b/code/1/1.1.c.and.cpp index 837626e..825c2e8 100644 --- a/code/1/1.1.c.and.cpp +++ b/code/1/1.1.c.and.cpp @@ -5,6 +5,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include "foo.h" diff --git a/code/1/Makefile b/code/1/Makefile index ed50295..09cde53 100644 --- a/code/1/Makefile +++ b/code/1/Makefile @@ -5,6 +5,7 @@ # modern cpp tutorial # # created by changkun at changkun.de +# https://github.com/changkun/modern-cpp-tutorial # C = gcc diff --git a/code/1/foo.c b/code/1/foo.c index 273bdd1..14b5050 100644 --- a/code/1/foo.c +++ b/code/1/foo.c @@ -5,6 +5,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include "foo.h" diff --git a/code/1/foo.h b/code/1/foo.h index f10bf6e..9ce74b8 100644 --- a/code/1/foo.h +++ b/code/1/foo.h @@ -5,6 +5,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #ifdef __cplusplus diff --git a/code/10/Makefile b/code/10/Makefile index 4477d7c..642b9bc 100644 --- a/code/10/Makefile +++ b/code/10/Makefile @@ -1,7 +1,14 @@ +# +# modern cpp tutorial +# +# created by changkun at changkun.de +# https://github.com/changkun/modern-cpp-tutorial +# + all: $(patsubst %.cpp, %.out, $(wildcard *.cpp)) %.out: %.cpp Makefile - clang++ $< -o $@ -std=c++2a -Xclang -fconcepts-ts -pedantic + clang++ $< -o $@ -std=c++2a -pedantic clean: rm *.out \ No newline at end of file diff --git a/code/2/2.01.nullptr.cpp b/code/2/2.01.nullptr.cpp index c0959f5..0b59157 100644 --- a/code/2/2.01.nullptr.cpp +++ b/code/2/2.01.nullptr.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.02.constexpr.cpp b/code/2/2.02.constexpr.cpp index 91fb0c0..7934ca6 100644 --- a/code/2/2.02.constexpr.cpp +++ b/code/2/2.02.constexpr.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.03.if.switch.cpp b/code/2/2.03.if.switch.cpp index 5651781..e596de1 100644 --- a/code/2/2.03.if.switch.cpp +++ b/code/2/2.03.if.switch.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include @@ -13,13 +14,12 @@ int main() { std::vector vec = {1, 2, 3, 4}; - // before c++17, can be simplefied by using `auto` + // after c++17, can be simplefied by using `auto` const std::vector::iterator itr = std::find(vec.begin(), vec.end(), 2); if (itr != vec.end()) { *itr = 3; } - // after c++17, can be simplefied by using `auto` if (const std::vector::iterator itr = std::find(vec.begin(), vec.end(), 3); itr != vec.end()) { *itr = 4; diff --git a/code/2/2.04.initializer.list.cpp b/code/2/2.04.initializer.list.cpp index 9f2dbe0..8caeeb9 100644 --- a/code/2/2.04.initializer.list.cpp +++ b/code/2/2.04.initializer.list.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.05.structured.binding.cpp b/code/2/2.05.structured.binding.cpp index e7f5ab1..48963f3 100644 --- a/code/2/2.05.structured.binding.cpp +++ b/code/2/2.05.structured.binding.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.06.auto.cpp b/code/2/2.06.auto.cpp index bf01d67..c9eaeb5 100644 --- a/code/2/2.06.auto.cpp +++ b/code/2/2.06.auto.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.07.decltype.cpp b/code/2/2.07.decltype.cpp index 6bac87a..7d48616 100644 --- a/code/2/2.07.decltype.cpp +++ b/code/2/2.07.decltype.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.08.tail.return.type.cpp b/code/2/2.08.tail.return.type.cpp index 414d4cd..c05796a 100644 --- a/code/2/2.08.tail.return.type.cpp +++ b/code/2/2.08.tail.return.type.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.09.decltype.auto.cpp b/code/2/2.09.decltype.auto.cpp index 5445fca..d48586a 100644 --- a/code/2/2.09.decltype.auto.cpp +++ b/code/2/2.09.decltype.auto.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // template diff --git a/code/2/2.10.if.constexpr.cpp b/code/2/2.10.if.constexpr.cpp index 97f6dc7..9042f2e 100644 --- a/code/2/2.10.if.constexpr.cpp +++ b/code/2/2.10.if.constexpr.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.11.for.loop.cpp b/code/2/2.11.for.loop.cpp index fd0d7bf..a843c40 100644 --- a/code/2/2.11.for.loop.cpp +++ b/code/2/2.11.for.loop.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.12.external.template.cpp b/code/2/2.12.external.template.cpp index 12262a7..ad31ff9 100644 --- a/code/2/2.12.external.template.cpp +++ b/code/2/2.12.external.template.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.13.alias.template.cpp b/code/2/2.13.alias.template.cpp index 2932b6f..a5355d4 100644 --- a/code/2/2.13.alias.template.cpp +++ b/code/2/2.13.alias.template.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.14.default.template.param.cpp b/code/2/2.14.default.template.param.cpp index 9809742..9351649 100644 --- a/code/2/2.14.default.template.param.cpp +++ b/code/2/2.14.default.template.param.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.15.variadic.template.param.cpp b/code/2/2.15.variadic.template.param.cpp index 849bacb..e43619f 100644 --- a/code/2/2.15.variadic.template.param.cpp +++ b/code/2/2.15.variadic.template.param.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.16.fold.expression.cpp b/code/2/2.16.fold.expression.cpp index 9926d8e..cdfbde5 100644 --- a/code/2/2.16.fold.expression.cpp +++ b/code/2/2.16.fold.expression.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/2.18.non.type.template.auto.cpp b/code/2/2.18.non.type.template.auto.cpp index e6d47fa..b2a1d43 100644 --- a/code/2/2.18.non.type.template.auto.cpp +++ b/code/2/2.18.non.type.template.auto.cpp @@ -4,6 +4,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/code/2/Makefile b/code/2/Makefile index fe333ed..642b9bc 100644 --- a/code/2/Makefile +++ b/code/2/Makefile @@ -1,3 +1,10 @@ +# +# modern cpp tutorial +# +# created by changkun at changkun.de +# https://github.com/changkun/modern-cpp-tutorial +# + all: $(patsubst %.cpp, %.out, $(wildcard *.cpp)) %.out: %.cpp Makefile diff --git a/code/2/todo/2.7.cpp b/code/2/todo/2.7.cpp index 1d01166..9a636d6 100644 --- a/code/2/todo/2.7.cpp +++ b/code/2/todo/2.7.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 面向对象增强 diff --git a/code/2/todo/2.8.cpp b/code/2/todo/2.8.cpp index fe9b736..2e87f57 100644 --- a/code/2/todo/2.8.cpp +++ b/code/2/todo/2.8.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 强类型枚举 diff --git a/code/3/3.1.cpp b/code/3/3.1.cpp index 4110ee1..7ddf0bf 100644 --- a/code/3/3.1.cpp +++ b/code/3/3.1.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // lambda expression diff --git a/code/3/3.2.cpp b/code/3/3.2.cpp index d213bd4..dd48ab1 100644 --- a/code/3/3.2.cpp +++ b/code/3/3.2.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // std::function std::bind diff --git a/code/3/3.3.cpp b/code/3/3.3.cpp index f34a30a..27727f7 100644 --- a/code/3/3.3.cpp +++ b/code/3/3.3.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 右值引用 rvalue reference diff --git a/code/3/3.4.cpp b/code/3/3.4.cpp index ca0e97a..6abeeee 100644 --- a/code/3/3.4.cpp +++ b/code/3/3.4.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 移动语义 diff --git a/code/3/3.5.cpp b/code/3/3.5.cpp index 2e38e23..76564c7 100644 --- a/code/3/3.5.cpp +++ b/code/3/3.5.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 移动语义 diff --git a/code/3/3.6.cpp b/code/3/3.6.cpp index 3249e17..1f2d789 100644 --- a/code/3/3.6.cpp +++ b/code/3/3.6.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 完美转发 diff --git a/code/4/4.1.cpp b/code/4/4.1.cpp index f879639..93304c8 100644 --- a/code/4/4.1.cpp +++ b/code/4/4.1.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // std::array diff --git a/code/4/4.2.cpp b/code/4/4.2.cpp index bfed726..c1694c7 100644 --- a/code/4/4.2.cpp +++ b/code/4/4.2.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 无序容器 diff --git a/code/4/4.3.cpp b/code/4/4.3.cpp index 5a88271..828aeae 100644 --- a/code/4/4.3.cpp +++ b/code/4/4.3.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // std::tuple 及其操作 diff --git a/code/7/7.1.cpp b/code/7/7.1.cpp index b673d8c..1e69a98 100644 --- a/code/7/7.1.cpp +++ b/code/7/7.1.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 线程支持库 diff --git a/code/7/7.2.cpp b/code/7/7.2.cpp index 99b6cdb..33e3bf4 100644 --- a/code/7/7.2.cpp +++ b/code/7/7.2.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // 生产者消费者模型 diff --git a/code/9/9.1.noexcept.cpp b/code/9/9.1.noexcept.cpp index c5b799a..c77f885 100644 --- a/code/9/9.1.noexcept.cpp +++ b/code/9/9.1.noexcept.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // noexcept diff --git a/code/9/9.2.literals.cpp b/code/9/9.2.literals.cpp index 3dee477..3109dfb 100644 --- a/code/9/9.2.literals.cpp +++ b/code/9/9.2.literals.cpp @@ -3,6 +3,7 @@ // modern c++ tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // // literals diff --git a/code/9/Makefile b/code/9/Makefile index fe333ed..642b9bc 100644 --- a/code/9/Makefile +++ b/code/9/Makefile @@ -1,3 +1,10 @@ +# +# modern cpp tutorial +# +# created by changkun at changkun.de +# https://github.com/changkun/modern-cpp-tutorial +# + all: $(patsubst %.cpp, %.out, $(wildcard *.cpp)) %.out: %.cpp Makefile diff --git a/exercises/2/fold.expresion.cpp b/exercises/2/fold.expresion.cpp index d42e336..cf98ecc 100644 --- a/exercises/2/fold.expresion.cpp +++ b/exercises/2/fold.expresion.cpp @@ -5,6 +5,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include diff --git a/exercises/2/structured.binding.cpp b/exercises/2/structured.binding.cpp index 465577f..8afebbc 100644 --- a/exercises/2/structured.binding.cpp +++ b/exercises/2/structured.binding.cpp @@ -5,6 +5,7 @@ // modern cpp tutorial // // created by changkun at changkun.de +// https://github.com/changkun/modern-cpp-tutorial // #include