|
You are here |
brevzin.github.io | ||
| | | | |
www.foonathan.net
|
|
| | | | | You probably know that C++20 adds ranges. Finally we can write copy(container, dest) instead of copy(container.begin(), container.end(), dest)! Ranges also do a lot more. Among other things, they add a new way of specifying an iterator to the end - sentinels. | |
| | | | |
www.cppstories.com
|
|
| | | | | In C++11, we got a handy way to initialize various containers. Rather than using push_back() or insert() several times, you can leverage a single constructor by taking an initializer list. For example, with a vector of strings, you can write: std::vector vec { "abc", "xyz", "***" }; We can also write expressions like: for (auto x : {1, 2, 3}) cout << x << ", "; The above code samples use std::initializer_list and (some compiler support) to hold the values and pass them around. Let's understa...... | |
| | | | |
entangledlogs.com
|
|
| | | | | Generic Programming: Generating part of programs Introduction Generic Programming: Programming with generic parameters to avoid unnecessary code duplication and encourage code reuse. Polymorphism is also another technique to solve code reuse Puts implicit constraints on the generic types that are to be fulfilled by concrete types. template T adder(T LHS, T RHS) { return LHS + RHS; } struct Foo { inv Val = 0; } Foo f = adder(Foo{}, Foo{}): In this code snippet, we assume that Foo meets the requirement tha... | |
| | | | |
www.stroustrup.com
|
|
| | | |||