![Page 1: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/1.jpg)
![Page 2: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/2.jpg)
![Page 3: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/3.jpg)
![Page 4: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/4.jpg)
![Page 5: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/5.jpg)
![Page 6: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/6.jpg)
![Page 7: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/7.jpg)
![Page 8: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/8.jpg)
switch (i){case 1:....break;
case 2:....break;
case 3:....[[fallthrough]]; // No warning
case 50:....break;
}
![Page 9: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/9.jpg)
void foo(std::vector &vec){
// some manipulations with vector
vec.empty(); // doesn't erase vector!}
![Page 10: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/10.jpg)
template <typename T, typename Alloc>class vector{....[[nodiscard]] bool empty() const noexcept { .... }
};
void foo(std::vector &vec){
// some manipulations with vector
vec.empty(); // warning: function result hasn't been used(void)vec.empty(); // return value has been ignored
}
![Page 11: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/11.jpg)
struct [[nodiscard]] Foo{
....};
enum [[nodiscard]] Bar{....
};
![Page 12: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/12.jpg)
void f(bool flag1, bool flag2){
bool b = thing1 && thing2;assert(b); // disappears in release mode
}
![Page 13: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/13.jpg)
[[maybe_unused]] void f([[maybe_unused]] bool flag1,[[maybe_unused]] bool flag2)
{[[maybe_unused]] bool b = thing1 && thing2; // No warningassert(b); // disappears in release mode
}
![Page 14: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/14.jpg)
struct [[maybe_unused]] S;
[[maybe_unused]] typedef S* PS;
using PS [[maybe_unused]] = S*;
[[maybe_unused]] int x;
union U {[[maybe_unused]] int n; };
[[maybe_unused]] void f();
enum [[maybe_unused]] E {};
enum { A [[maybe_unused]], B [[maybe_unused]] = 42 };
![Page 15: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/15.jpg)
![Page 16: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/16.jpg)
void foo() throw(A, B);
![Page 17: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/17.jpg)
void foo() throw(A, B);
void (*pf1)() throw(A, B); // okpf1 = foo;
![Page 18: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/18.jpg)
void foo() throw(A, B);
void (*pf1)() throw(A, B); // okpf1 = foo;
class C{
virtual void f() throw(A, B); };
class D : C{
void f(); // compile-time error};
![Page 19: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/19.jpg)
void foo() throw(A, B);
void (*pf1)() throw(A, B); // okpf1 = foo;
class C{
virtual void f() throw(A, B); };
class D : C{
void f(); // compile-time error};
typedef void (*Pf2)() throw(A, B); // compile-time errorPf2 pf = f;
![Page 20: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/20.jpg)
throw(A, B, ...) // removedthrow() -> deprecatedthrow() ≡ noexcept
typedef void (*nef)() noexcept; // oktypedef void (*ef)(); // ok
void foo() noexcept;void bar();
ef pf1 = foo; // oknef pf2 = foo; // ok
ef pf3 = bar; // oknef pf4 = bar; // compile-time error
![Page 21: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/21.jpg)
![Page 22: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/22.jpg)
// until C++17std::pair<int, int> pair { 0, 0 };auto pair = std::pair<int, int> { 0, 0 };
std::mutex mutex;std::lock_guard<std::mutex> lock { mutex };
![Page 23: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/23.jpg)
// until C++17std::pair<int, int> pair { 0, 0 };auto pair = std::pair<int, int> { 0, 0 };
std::mutex mutex;std::lock_guard<std::mutex> lock { mutex };
// since C++17std::pair pair { 0, 0 };auto pair = std::pair { 0, 0 };
std::lock_guard lock { mutex };
![Page 24: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/24.jpg)
namespace std{
template <class Mutex>class lock_guard{
explicit lock_guard(Mutex &mtx) { mtx.lock(); .... }....
};}
![Page 25: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/25.jpg)
namespace std{
template <class Mutex>class lock_guard{
explicit lock_guard(Mutex &mtx) { mtx.lock(); .... }....
};
// template <class Mutex>// explicit lock_guard(Mutex &mtx) -> lock_guard<Mutex>;
}
![Page 26: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/26.jpg)
std::mutex mutex;
std::lock_guard lock { mutex };
![Page 27: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/27.jpg)
std::mutex mutex;
std::lock_guard lock { mutex };
// auto lock = std::lock_guard(mutex);
![Page 28: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/28.jpg)
std::mutex mutex;
std::lock_guard lock { mutex };
// auto lock = std::lock_guard(mutex);
// template <class Mutex>// explicit lock_guard(Mutex &mtx) -> lock_guard<Mutex>;
// explicit lock_guard<std::mutex>(std::mutex &mtx);
// Mutex ≡ std::mutex
std::lock_guard<std::mutex> lock { mutex }; // PROFIT!!!
![Page 29: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/29.jpg)
// <array> header
namespace std{template <class T, size_t N>struct array{
T arr[N];....
};}
std::array<int, 5> arr { 0, 1, 2, 3, 4 };
![Page 30: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/30.jpg)
// <array> header
namespace std{template <class T, size_t N>struct array{
T arr[N];....
};
template <class T, class ...U>array(T, U...) -> array<T, sizeof...(U) + 1>;
}
std::array<int, 5> arr { 0, 1, 2, 3, 4 };
![Page 31: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/31.jpg)
std::array arr { 0, 1, 2, 3, 4 };
// auto arr = std::array(0, 1, 2, 3, 4);
// template <class T, class ...U>// array(T, U...) -> array<T, sizeof...(U) + 1>;
// array<int, int, int, int, int>(int, int, int, int, int);
// T ≡ int// U ≡ (int, int, int ,int)// sizeof...(U) == 4
std::array<int, 5> arr { 0, 1, 2, 3, 4 }; // PROFIT!!!
![Page 32: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/32.jpg)
![Page 33: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/33.jpg)
template <typename Type, Type n>struct integral_constant{....using value_type = Type;static constexpr value_type value = n;
};
using true_type = integral_constant<bool, true>;using false_type = integral_constant<bool, false>;
![Page 34: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/34.jpg)
template <auto Val> // template <decltype(auto) Val>struct integral_constant{....using value_type = decltype(Val);static constexpr value_type value = Val;
};
using true_type = integral_constant<true>;using false_type = integral_constant<false>;
![Page 35: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/35.jpg)
![Page 36: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/36.jpg)
using Person = std::tuple<std::string, std::string, uint8_t>;
Person foo(size_t idx){....
}
void bar(){
size_t idx = ....;
std::string name, surname;uint8_t age;
std::tie(name, surname, age) = foo(idx);....
}
![Page 37: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/37.jpg)
using Person = std::tuple<std::string, std::string, uint8_t>;
Person foo(size_t idx){....
}
void bar(){
size_t idx = ....;
auto [name, surname, age] = foo(idx); // since C++17....
}
![Page 38: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/38.jpg)
void bar(){
size_t idx = ....;
// auto [name, surname, age] = foo(idx);auto &&__sym_1_2 = foo(idx);
auto name = std::get<0>(__sym_1_2); // std::stringauto surname = std::get<1>(__sym_1_2); // std::stringauto age = std::get<2>(__sym_1_2); // uint8_t....
}
![Page 39: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/39.jpg)
void bar(){
size_t idx = ....;
// auto &[name, surname, age] = foo(idx);auto &&__sym_1_2 = foo(idx);
auto &name = std::get<0>(__sym_1_2); // std::string &auto &surname = std::get<1>(__sym_1_2); // std::string &auto &age = std::get<2>(__sym_1_2); // uint8_t &....
}
![Page 40: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/40.jpg)
void bar(){
size_t idx = ....;
// auto &&[name, surname, age] = foo(idx);auto &&__sym_1_2 = foo(idx);
auto &&name = std::get<0>(__sym_1_2); // std::string &&auto &&surname = std::get<1>(__sym_1_2); // std::string &&auto &&age = std::get<2>(__sym_1_2); // uint8_t &&....
}
![Page 41: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/41.jpg)
void bar(){
size_t idx = ....;
// const auto &[name, surname, age] = foo(idx);auto &&__sym_1_2 = foo(idx);
// const std::string &const auto &name = std::get<0>(__sym_1_2);
// const std::string &const auto &surname = std::get<1>(__sym_1_2);
// const uint8_t &const auto &age = std::get<2>(__sym_1_2); ....
}
![Page 42: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/42.jpg)
void bar(){
int arr[3] = { 0, 1, 2 };auto [elem1, elem2, elem3] = arr;
std::tuple<std::string, std::string, uint8_t> person { .... };auto [name, surname, age] = person;
template <typename T1, typename T2>struct Pair { T1 first; T2 second; };
auto [first, second] = Pair { .... };}
![Page 43: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/43.jpg)
class Person{
std::string m_name, m_surname;
public:Person(std::string name, std::string surname) : .... { .... }
const std::string& GetName() const noexcept { .... }const std::string& GetSurname() const noexcept { .... }
};
![Page 44: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/44.jpg)
template <size_t N>decltype(auto) get(const Person &);
template <>decltype(auto) get<0>(const Person &p){
return p.GetName();}
template <>decltype(auto) get<1>(const Person &p){
return p.GetSurname();}
![Page 45: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/45.jpg)
namespace std{
template <>struct tuple_size<Person> : std::integral_constant<size_t, 2>{ };
template <>struct tuple_element<0, Person>{
using type = const std::string &;};
template <>struct tuple_element<1, Person>{
using type = const std::string &;};
}
![Page 46: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/46.jpg)
void bar(){
auto &&[name, surname] = Person { "Phillip", "Khandeliants" };
// name's type ≡ const std::string &// name == "Phillip"
// surname's type ≡ const std::string &// surname == "Khandeliants"
}
![Page 47: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/47.jpg)
![Page 48: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/48.jpg)
void bar(){
using std::literals;
auto str = "I heard it even works if you don't believe"s;
str.replace(0, 8, "").replace(s.find("even"), 4, "sometimes").replace(s.find(" don't"), 6, "");
assert(s == "it sometimes works if you believe");}
![Page 49: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/49.jpg)
void bar(){
using std::literals;
auto str = "I heard it even works if you don't believe"s;
str.replace(0, 8, "").replace(s.find("even"), 4, "sometimes").replace(s.find(" don't"), 6, "");
assert(s == "it sometimes works if you believe");}
// s == "it sometimes works if you believe"
// s == "itsometimesn works if you dolieve"// s == "itsometimesn works idon't believe"
![Page 50: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/50.jpg)
a.b
a->b
a->*b
a(b1, b2, b3)
b @= a
a[b]
a << b << c
a >> b >> c
![Page 51: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/51.jpg)
![Page 52: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/52.jpg)
// before C++17
auto v1 { 1, 2, 3 }; // std::initializer_list<int>
auto v2 = { 1, 2, 3 }; // std::initializer_list<int>
auto v3 { 42 }; // std::initializer_list<int>
auto v4 = { 42 }; // std::initializer_list<int>
![Page 53: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/53.jpg)
// before C++17
auto v1 { 1, 2, 3 }; // std::initializer_list<int>
auto v2 = { 1, 2, 3 }; // std::initializer_list<int>
auto v3 { 42 }; // std::initializer_list<int>
auto v4 = { 42 }; // std::initializer_list<int>
// since C++17
auto v1 { 1, 2, 3 }; // compile-time error
auto v2 = { 1, 2, 3 }; // std::initializer_list<int>
auto v3 { 42 }; // int
auto v4 = { 42 }; // std::initializer_list<int>
![Page 54: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/54.jpg)
![Page 55: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/55.jpg)
std::string helloWorld(){
return "Hello, World"; // construct temporary std::string}
void bar(){
std::string str = helloWorld(); // move temporary object}
![Page 56: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/56.jpg)
std::string helloWorld(){
return "Hello, World"; // Return value optimization}
void bar(){
std::string str = helloWorld(); // construct object in-place}
![Page 57: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/57.jpg)
template <typename T>T foo(){
return T();}
template <typename T>void bar(){
T tmp = T(T(foo<T>())); // no copy/move constructors called}
![Page 58: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/58.jpg)
template <typename T>T foo(){
return T();}
template <typename T>void bar(T param){
....}
template <typename T>void foobar(){
bar(foo<T>()); // construct parameter in-place}
![Page 59: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/59.jpg)
![Page 60: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/60.jpg)
template <typename T>constexpr auto sum(T t){
return t;}
template <typename T, typename ...Types>constexpr auto sum(T t1, Types ...tN){
return t1 + sum(tN...);}
constexpr size_t res = sum(0, 1, 2, 3);
![Page 61: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/61.jpg)
constexpr size_t res = sum(0, 1, 2, 3);
// sum(0, 1, 2, 3) ≡ return 0 + sum(1, 2, 3);// sum(1, 2, 3) ≡ return 1 + sum(2, 3);// sum(2, 3) ≡ return 2 + sum(3);// sum(3) ≡ return 3;
// sum(0, 1, 2, 3) ≡ return 0 + 1 + 2 + 3;
// sum(0, 1, 2, 3) == 6
![Page 62: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/62.jpg)
template <typename T, typename ...Types>constexpr auto sum(T t1, Types ...tN){
return (t1 + ... + tN);}
constexpr auto res = sum(0, 1, 2, 3);
// sum(0, 1, 2, 3) ≡ return (((0 + 1) + 2) + 3);
![Page 63: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/63.jpg)
(pack op ...) ≡ (E1 op (... op (EN-1 op EN)))
(... op pack) ≡ (((E1 op E2) op ...) op EN)
(pack op ... op init) ≡ (E1 op (... op (EN−1 op (EN op I))))
(init op ... op pack) ≡ ((((I op E1) op E2) op ...) op EN)
op ::= '+' '-' '*' '/' '%' '^' '&' '|' '=' '<' '>'
'<<' '>>' '+=' '-=' '*=' '/=' '%=' '^=' '&='
'|=' '<<=' '>>=' '==' '!=' '<=' '>=' '&&' '||'
',' '.*' '->*'
![Page 64: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/64.jpg)
// before С++17
template <typename ...Args>void pass(Args &&...) { }
template <typename ...Types>void print(const Types &...tN){pass( ( [&]{ std::cout << tN; }(), 0 )... );
}
print("Hello, ", "World");
![Page 65: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/65.jpg)
// since C++17
template <typename ...Types>void print(const Types &...tN){
(std::cout << ... << tN);}
![Page 66: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/66.jpg)
![Page 67: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/67.jpg)
struct Base{
std::string name, surname;};
struct Derived : Base{
uint8_t age;};
Derived d1; // name and surname are empty// age contains undefined value;
Derived d2 {}; // age == 0
Derived d3 { { "Phillip", "Khandeliants" }, 24 }; // ok since C++17
Derived d4 { "Phillip", "Khandeliants", 24 }; // ok since C++17
![Page 68: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/68.jpg)
struct Base{
std::string name, surname;};
struct Derived : Base{
Derived() = delete;uint8_t age;
};
Derived d1; // compile-time error, default constructor is deleted
Derived d2 {}; // ok!!!!
![Page 69: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/69.jpg)
![Page 70: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/70.jpg)
class SomeClass{
int m_x = 0;
void f() const noexcept { std::cout << m_x << '\n'; }void g() noexcept { ++m_x; }
void foo(){
// before C++17auto lambda1 = [self = *this]() { self.f(); };auto lambda2 = [self = *this]() mutable { self.g(); }
lambda1();lambda2();
}};
![Page 71: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/71.jpg)
class SomeClass{
int m_x = 0;
void f() const noexcept { std::cout << m_x << '\n'; }void g() noexcept { ++m_x; }
void foo(){
// since C++17auto lambda1 = [*this]() { f(); };auto lambda2 = [*this]() mutable { g(); }
lambda1();lambda2();
}};
![Page 72: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/72.jpg)
![Page 73: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/73.jpg)
std::map<std::string, uint8_t> persons;
void find_person(const std::string &name){const auto it = m.find(name);if (it != persons.end()){
....}
// 'it' is visible here}
![Page 74: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/74.jpg)
std::map<std::string, uint8_t> persons;
void find_person(const std::string &name){if (const auto it = m.find(name); it != persons.end()){
....}
// 'it' isn't visible here}
![Page 75: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/75.jpg)
std::map<std::string, uint8_t> persons;
void find_person(const std::string &name){{
const auto it = m.find(name);if (it != persons.end()){
....}
}
// 'it' isn't visible here}
![Page 76: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/76.jpg)
std::map<std::string, uint8_t> persons;
void find_person(const std::string &name){if (const auto it = m.find(name); it != persons.end()){
....}else if (const auto it = ....; ....){
....}
// 'it' isn't visible here}
![Page 77: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/77.jpg)
std::map<std::string, uint8_t> persons;
void find_person(const std::string &name){{
const auto it = m.find(name);if (it != persons.end()){
....}else{
const auto it = ....; // hides previous 'it' declarationif (....) { .... }
}}
// 'it' isn't visible here}
![Page 78: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/78.jpg)
std::map<std::string, uint8_t> persons;
void insert_person(std::string name, uint8_t age){if (auto [it, ok] = persons.emplace(std::move(name), age); ok){
....}
}
![Page 79: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/79.jpg)
![Page 80: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/80.jpg)
class Person{
std::string m_name, m_surname;
public:Person(std::string name, std::string surname) : .... { .... }
const std::string& GetName() const noexcept { .... }const std::string& GetSurname() const noexcept { .... }
};
![Page 81: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/81.jpg)
template <size_t N>decltype(auto) get(const Person &);
template <>decltype(auto) get<0>(const Person &p){
return p.GetName();}
template <>decltype(auto) get<1>(const Person &p){
return p.GetSurname();}
![Page 82: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/82.jpg)
// since C++17
template <size_t N>decltype(auto) get(const Person &){
if constexpr (N == 0){
return p.GetName();}else if constexpr (N == 1){
return p.GetSurname();}
}
![Page 83: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/83.jpg)
![Page 84: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/84.jpg)
// MyLibrary.h
#pragma once
void foo(....){
....}
![Page 85: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/85.jpg)
// MyLibrary.h
#pragma once
void foo(....){
....}
// TU1.cpp
#include "MyLibrary.h"
void bar(){
foo(....);}
// TU2.cpp
#include "MyLibrary.h"
void foobar(){foo(....);
}
![Page 86: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/86.jpg)
1>TU1.cpp1>TU2.cpp1>TU2.obj : error LNK2005: "void __cdecl foo(void)" (?foo@@YAXXZ) already defined in main.obj1>TestExamples.exe : fatal error LNK1169: one or more multiply defined symbols found
![Page 87: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/87.jpg)
1>TU1.cpp1>TU2.cpp1>TU2.obj : error LNK2005: "void __cdecl foo(void)" (?foo@@YAXXZ) already defined in main.obj1>TestExamples.exe : fatal error LNK1169: one or more multiply defined symbols found
![Page 88: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/88.jpg)
// MyLibrary.h
#pragma once
inline void foo(....){
....}
![Page 89: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/89.jpg)
// MyLibrary.h
#pragma once
int foobar = ....;
// TU1.cpp
#include "MyLibrary.h"
void bar(){
foobar = 0;}
// TU2.cpp
#include "MyLibrary.h"
void foobar(){assert(foobar == 0);
}
![Page 90: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/90.jpg)
// MyLibrary.h
#pragma once
inline int foobar = ....;
![Page 91: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/91.jpg)
![Page 92: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/92.jpg)
#if __has_include(<optional>)#include <optional>#define have_optional 1
#elif __has_include(<experimental/optional>)#include <experimental/optional>#define have_optional 1#define experimental_optional 1
#else#define have_optional 0
#endif
![Page 93: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/93.jpg)
![Page 94: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/94.jpg)
struct alignas(32) S{
int a;char c;
};
int main(){
S *objects = new S[10];....
detele[] objects;return 0;
}
![Page 95: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/95.jpg)
![Page 96: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/96.jpg)
static_assert ( constant-expression , string-literal ) ;
static_assert(a == 42, "a must be equal to 42");
static_assert ( constant-expression ) ;
static_assert(a == 42);
<source>:57:3: error: static_assert failedstatic_assert(a == 42);^ ~~~~~
1 error generated.
![Page 97: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/97.jpg)
![Page 98: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/98.jpg)
// before C++17
void foo(const std::string &str) { .... }
![Page 99: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/99.jpg)
// before C++17
void foo(const std::string &str) { .... }void foo(const char *str) { .... }void foo(const char *str, size_t len) { .... }
template <size_t N>void foo(const char (&str)[N]) { .... }
![Page 100: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/100.jpg)
// before C++17
void foo(const std::string &str) { .... }void foo(const char *str) { .... }void foo(const char *str, size_t len) { .... }
template <size_t N>void foo(const char (&str)[N]) { .... }
// since C++17
void foo(std::string_view str) { .... }
![Page 101: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/101.jpg)
#include <string_view>
template <typename CharT, typename Traits = char_traits<CharT>>class basic_string_view;
using string_view = basic_string_view<char>;using u16string_view = basic_string_view<char16_t>;using u32string_view = basic_string_view<char32_t>;using wstring_view = basic_string_view<wchar_t>;
![Page 102: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/102.jpg)
#include <string_view>
template <typename CharT, typename Traits = char_traits<CharT>>class basic_string_view;
using string_view = basic_string_view<char>;using u16string_view = basic_string_view<char16_t>;using u32string_view = basic_string_view<char32_t>;using wstring_view = basic_string_view<wchar_t>;
template <typename CharT>void foo(std::basic_string_view<CharT> str) { .... }
![Page 103: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/103.jpg)
std::vector<std::string> vec;....
std::sort(vec.begin(), vec.end(),[](const std::string &lhs, const std::string &rhs){
return lhs.substr(3) < rhs.substr(3);});
![Page 104: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/104.jpg)
std::vector<std::string> vec;....
std::sort(vec.begin(), vec.end(),[](std::string_view lhs, std::string_view rhs){
return lhs.substr(3) < rhs.substr(3);});
![Page 105: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/105.jpg)
![Page 106: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/106.jpg)
// returns 0, if fails
int atoi(const char *str); long atol(const char *str);long long atoll(const char *str);
// returns 0 if no conversion can be performed// sets errno to ERANGE if converted value is out of range// sets str_end pointer to the last incorrect symbol
long strtol(const char *str, char **str_end, int base);long long strtoll(const char *str, char **str_end, int base);
![Page 107: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/107.jpg)
// throws std::invalid_argument if no conversion can be performed// throws std::out_of_range if converted value is out of range
// sets size_t value addressed by pointer to the last incorrect// symbol
// returns value if conversion can be performed
int stoi(const std::string &str, size_t *pos = 0, int base = 10);long stol(const std::string &str, size_t *pos = 0, int base = 10);long long stoll(const std::string &str, size_t *pos = 0, int base = 10);
![Page 108: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/108.jpg)
#include <sstream>
template <typename T>T to_integral(const std::string &str){T res {};std::ostringstream converter { str };converter >> res;return res;
}
![Page 109: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/109.jpg)
#include <charconv>
template <typename T>T to_integral(std::string_view str){T num {};auto res = std::from_chars(str.data(), str.data() + str.size(), num);return num;
}
![Page 110: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/110.jpg)
![Page 111: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/111.jpg)
#include <charconv>
template <typename T>T to_integral(std::string_view str){T num {};auto res = std::from_chars(str.data(), str.data() + str.size(), num);return num;
}
![Page 112: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/112.jpg)
#include <charconv>#include <optional>
template <typename T>std::optional<T> to_integral(std::string_view str){T num {};auto res = std::from_chars(str.data(), str.data() + str.size(), num);
return res.ec == std::errc {} ? std::optional { num } : std::nullopt;
}
![Page 113: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/113.jpg)
void foo(const std::string &str){
const auto num = to_integral<uint64_t>(str); // std::optional
auto tmp1 = *num; // UB if num == std::nullopt
auto tmp2 = num.value(); // throws exception // if num == std::nullopt
if (num) // num.has_value(){
....}else // std::nullopt{
....}
}
![Page 114: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/114.jpg)
void foo(const std::string &str){
const auto num = to_integral<uint64_t>(str); // std::optional
auto tmp = num.value_or({}); // value from std::optional// or default value// if num == std::nullopt
if (num < 10) // returns true if num == std::nullopt// or compares underlying value// with another value
{....
}}
![Page 115: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/115.jpg)
class SomeClass { public: void bar() { .... } };
void foo(){std::optional obj { SomeClass {} }; // std::optional<SomeClass>
obj->bar(); // SomeClass::bar}
![Page 116: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/116.jpg)
![Page 117: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/117.jpg)
#include <variant>
using Type = std::variant<size_t, double, std::string>;
Type var; // size_t by default
var = "Hello, I'm variant"; // std::stringvar = size_t {0}; // size_tvar = 3.14; // double
var = Type { std::in_place_index<2>, 3, 'A' }; // "AAA"var = Type { std::in_place_type<std::string>, 3, 'A'}; // "AAA"
![Page 118: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/118.jpg)
#include <variant>
std::variant<size_t, double, std::string> var; // size_t
var = "Hello, I'm variant"; // std::string
auto str = std::get<2>(var); // std::stringauto str = std::get<std::string>(var); // std::string
auto d = std::get<1>(var); // throws exception
![Page 119: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/119.jpg)
#include <variant>
std::variant<size_t, double, std::string> var; // size_t
var = "Hello, I'm variant"; // std::string
auto str = std::get<2>(var); // std::stringauto str = std::get<std::string>(var); // std::string
auto d = std::get<1>(var); // throws exception
auto f = std::get<float>(var); // compile-time error
![Page 120: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/120.jpg)
#include <variant>
std::variant<size_t, double, std::string> var; // size_t
var = "Hello, I'm variant"; // std::string
auto str = *std::get_if<2>(&var); // std::stringauto str = *std::get_if<std::string>(&var); // std::string
if (std::get_if<double>(&var) == nullptr) // true{
....}
![Page 121: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/121.jpg)
#include <variant>
struct S{
S(int i) : m_i { i } {}int m_i;
};
struct U{
U(double d) : m_d { d } {}double m_d;
};
std::variant<S, U> var1; // compile-time errorstd::variant<std::monostate, S, U> var2; // ok
![Page 122: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/122.jpg)
struct Shape{
virtual void draw() const noexcept = 0;};
struct Circle : Shape{
virtual void draw const noexcept override { .... }};
struct Rectangle : Shape{
virtual void draw const noexcept override { .... }};
![Page 123: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/123.jpg)
std::vector<std::unique_ptr<Shape>> shapes;
shapes.push_back(std::make_unique<Circle>(....));shapes.push_back(std::make_unique<Rectangle>(....));....
for (auto &&shape : shapes){shape->draw();
}
![Page 124: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/124.jpg)
struct Shape{
virtual void draw() const noexcept = 0;};
struct Circle : Shape{
virtual void draw const noexcept override { .... }};
struct Rectangle : Shape{
virtual void draw const noexcept override { .... }};
using Shape = std::variant<Circle, Rectangle>;
![Page 125: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/125.jpg)
std::vector<Shape> shapes;
shapes.push_back(Circle { .... });shapes.push_back(Rectangle { .... });....
struct Printer{void operator()(const Circle &obj) { obj.draw(); }void operator()(const Rectangle &obj) { obj.draw(); }
};
for (auto &&shape : shapes){
std::visit(Printer {}, shape);}
![Page 126: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/126.jpg)
std::vector<Shape> shapes;
shapes.push_back(Circle { .... });shapes.push_back(Rectangle { .... });....
for (auto &&shape : shapes){std::visit([](const auto &obj) { obj.draw(); }, shape);
}
![Page 127: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/127.jpg)
![Page 128: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/128.jpg)
std::any a = 1; // inta = 3.14; // double
std::cout << std::any_cast<float>(a) << '\n'; // throws exceptionstd::cout << std::any_cast<double>(a) << '\n'; // ok
const auto &typeInfo = a.type(); // RTTI
if (a.has_value()){
....}
a.reset();
![Page 129: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/129.jpg)
![Page 130: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/130.jpg)
#include <filesystem>
int main(int argc, char *argv[]){namespace fs = std::filesystem;for(auto &&entity: fs::directory_iterator(argv[0])){
switch (entity.status().type()){case file_type::regular:
....case file_type::directory:
....case file_type::symlink:
....}
}}
![Page 131: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/131.jpg)
#include <filesystem>
explicit directory_iterator(const path &p);
directory_iterator(const path &p, error_code &ec);
![Page 132: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/132.jpg)
![Page 133: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/133.jpg)
#include <algorithm>#include <vector>
std::for_each(std::execution::par, vec.begin(), vec.end(),[](auto &e) { e += 42; });
inline constexpr sequenced_policy seq { /* unspecified */ };
inline constexpr parallel_policy par { /* unspecified */ };
inline constexpr parallel_unsequenced_policy par_unseq{ /* unspecified */ };
![Page 134: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/134.jpg)
![Page 135: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/135.jpg)
⬛
![Page 136: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/136.jpg)
⬛
⬛
![Page 137: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/137.jpg)
⬛
⬛
⬛
![Page 138: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/138.jpg)
⬛
⬛
⬛
⬛
![Page 139: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/139.jpg)
⬛
⬛
⬛
⬛
⬛
![Page 140: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/140.jpg)
⬛
⬛
⬛
⬛
⬛
⬛
![Page 141: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/141.jpg)
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 142: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/142.jpg)
![Page 143: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/143.jpg)
⬛
namespace std::detail { .... }
![Page 144: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/144.jpg)
⬛
namespace std::detail { .... }
⬛
![Page 145: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/145.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
![Page 146: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/146.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
![Page 147: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/147.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
![Page 148: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/148.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
![Page 149: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/149.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
![Page 150: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/150.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 151: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/151.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 152: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/152.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 153: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/153.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 154: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/154.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 155: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/155.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 156: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/156.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 157: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/157.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 158: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/158.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 159: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/159.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 160: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/160.jpg)
⬛
namespace std::detail { .... }
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
⬛
![Page 161: Презентация PowerPoint€¦ · void foo(std::vector &vec) {// some manipulations with vector vec.empty(); // doesn't erase vector!}](https://reader036.vdocuments.us/reader036/viewer/2022063007/5fb8cfb0b8c8b7224f767e14/html5/thumbnails/161.jpg)