book: add missing header files (#74)

This commit is contained in:
Swastik Baranwal
2019-09-18 19:57:08 +05:30
committed by Ou Changkun
parent 934eb895c5
commit 0aa031f0f6
3 changed files with 14 additions and 1 deletions

View File

@@ -138,7 +138,7 @@ Don't worry at the moment, we will come to meet them in our later chapters.
## Further Readings
- [A Tour of C++ (2nd Edition) Bjarne Stroustrup](https://www.amazon.com/dp/0134997832/ref=cm_sw_em_r_mt_dp_U_GogjDbHE2H53B)
- [C++ History](http://en.cppreference.com/w/cpp/language/history)
[History of C++](http://en.cppreference.com/w/cpp/language/history)
- [C++ compiler support](https://en.cppreference.com/w/cpp/compiler_support)
- [Incompatibilities Between ISO C and ISO C++](http://david.tribble.com/text/cdiffs.htm#C99-vs-CPP98)

View File

@@ -286,6 +286,7 @@ such as:
```cpp
#include <initializer_list>
#include <vector>
class MagicFoo {
public:
std::vector<int> vec;
@@ -342,6 +343,7 @@ and the structured bindings let us write code like this:
```cpp
#include <iostream>
#include <tuple>
std::tuple<int, double, std::string> f() {
return std::make_tuple(1, 2.3, "456");
@@ -776,6 +778,7 @@ how to unpack the parameters?
First, we can use `sizeof...` to calculate the number of arguments:
```cpp
#include <iostream>
template<typename... Ts>
void magic(Ts... args) {
std::cout << sizeof...(args) << std::endl;
@@ -919,6 +922,7 @@ C++11 introduces the concept of a delegate construct, which allows a constructor
in a constructor in the same class, thus simplifying the code:
```cpp
#include <iostream>
class Base {
public:
int value1;
@@ -943,6 +947,7 @@ int main() {
In traditional C++, constructors need to pass arguments one by one if they need inheritance, which leads to inefficiency. C++11 introduces the concept of inheritance constructors using the keyword using:
```cpp
#include <iostream>
class Base {
public:
int value1;
@@ -1091,6 +1096,10 @@ This section introduces the enhancements to language usability in modern C++, wh
1. Using structured binding, implement the following functions with just one line of function code:
```cpp
#include <string>
#include <map>
#include <iostream>
template <typename Key, typename Value, typename F>
void update(std::map<Key, Value>& m, F foo) {
// TODO: