-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCppLambda.cc
More file actions
138 lines (114 loc) · 6.19 KB
/
CppLambda.cc
File metadata and controls
138 lines (114 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Utilities library
#include <cstdlib> // General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search
#include <csignal> // Functions and macro constants for signal management
#include <csetjmp> // Macro (and function) that saves (and jumps) to an execution context
#include <cstdarg> // Handling of variable length argument lists
#include <typeinfo> // Runtime type information utilities
#include <typeindex> // (since C++11) std::type_index
#include <type_traits> // (since C++11) Compile-time type information
#include <bitset> // std::bitset class template
#include <functional> // Function objects, designed for use with the standard algorithms
#include <utility> // Various utility components
#include <ctime> // C-style time/date utilites
#include <chrono> // (since C++11) C++ time utilites
#include <cstddef> // typedefs for types such as size_t, NULL and others
#include <initializer_list> // (since C++11) std::initializer_list class template
#include <tuple> // (since C++11) std::tuple class template
// Dynamic memory management
#include <new> // Low-level memory management utilities
#include <memory> // Higher level memory management utilities
#include <scoped_allocator> // (since C++11) Nested allocator class
// Numeric limits
#include <climits> // limits of integral types
#include <cfloat> // limits of float types
#include <cstdint> // (since C++11) fixed-size types and limits of other types
#include <cinttypes> // (since C++11) formatting macros , intmax_t and uintmax_t math and conversions
#include <limits> // standardized way to query properties of fundamental types
// Error handling
#include <exception> // Exception handling utilities
#include <stdexcept> // Standard exception objects
#include <cassert> // Conditionally compiled macro that compares its argument to zero
#include <system_error> // (since C++11) defines std::error_code, a platform-dependent error code
#include <cerrno> // Macro containing the last error number
// Strings library
#include <cctype> // functions to determine the type contained in character data
#include <cwctype> // functions for determining the type of wide character data
#include <cstring> // various narrow character string handling functions
#include <cwchar> // various wide and multibyte string handling functions
// #include <cuchar> // (since C++11) C-style Unicode character conversion functions
#include <string> // std::basic_string class template
// Containers library
#include <array> // (since C++11) std::array container
#include <vector> // std::vector container
#include <deque> // std::deque container
#include <list> // std::list container
#include <forward_list> // (since C++11) std::forward_list container
#include <set> // std::set and std::multiset associative containers
#include <map> // std::map and std::multimap associative containers
#include <unordered_set> // (since C++11) std::unordered_set and std::unordered_multiset unordered associative containers
#include <unordered_map> // (since C++11) std::unordered_map and std::unordered_multimap unordered associative containers
#include <stack> // std::stack container adaptor
#include <queue> // std::queue and std::priority_queue container adaptors
// Algorithms library
#include <algorithm> // Algorithms that operate on containers
// Iterators library
#include <iterator> // Container iterators
// Numerics library
#include <cmath> // Common mathematics functions
#include <complex> // Complex number type
#include <valarray> // Class for representing and manipulating arrays of values
#include <random> // (since C++11) Random number generators and distributions
#include <numeric> // Numeric operations on values in containers
#include <ratio> // (since C++11) Compile-time rational arithmetic
#include <cfenv> // (since C++11) Floating-point environment access functions
// Input/output library
#include <iosfwd> // forward declarations of all classes in the input/output library
#include <ios> // std::ios_base class, std::basic_ios class template and several typedefs
#include <istream> // std::basic_istream class template and several typedefs
#include <ostream> // std::basic_ostream, std::basic_iostream class templates and several typedefs
#include <iostream> // several standard stream objects
#include <fstream> // std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs
#include <sstream> // std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs
#include <iomanip> // Helper functions to control the format or input and output
#include <streambuf> // std::basic_streambuf class template
#include <cstdio> // C-style input-output functions
// Localization library
#include <locale> // Localization utilities
#include <clocale> // C localization utilities
// #include <codecvt> // (since C++11) Unicode conversion facilities
// Regular Expressions library
#include <regex> // (since C++11) Classes, algorithms and iterators to support regular expression processing
// Atomic Operations library
#include <atomic> // (since C++11) Atomic operations library
// Thread support library
#include <thread> // (since C++11) std::thread class and supporting functions
#include <mutex> // (since C++11) mutual exclusion primitives
// #include <shared_mutex> // (since C++14) shared mutual exclusion primitives
#include <future> // (since C++11) primitives for asynchronous computations
#include <condition_variable> // (since C++11) thread waiting conditions
using namespace std;
// =================================================
int main()
{
int a = 1, b = 1, c = 1;
auto m1 = [a, &b, &c]() mutable
{
auto m2 = [a, b, &c]() mutable
{
std::cout << a << b << c << '\n';
a = 4;
b = 4;
c = 4;
};
a = 3;
b = 3;
c = 3;
m2();
};
a = 2;
b = 2;
c = 2;
m1(); // calls m2() and prints 123
std::cout << a << b << c << '\n'; // prints 234
return 0;
}