hello i have found this code on windows documentation
but i don't get what means
[&]
just please can you clear me what it should do ??
it is not c++ standard true??
This is the code:
void parallel_matrix_multiply(double** m1, double** m2, double** result, size_t size)
{
parallel_for (size_t(0), size, [&](size_t i)
{
for (size_t j = 0; j < size; j++)
{
double temp = 0;
for (int k = 0; k < size; k++)
{
temp += m1[i][k] * m2[k][j];
}
result[i][j] = temp;
}
});
}
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
Full form of C is “COMPILE”. One thing which was missing in C language was further added to C++ that is 'the concept of CLASSES'.
It introduces a lambda expression. The contents of the square brackets
indicate what is to be captured inside the lambda. Having only a &
in there means that everything that is mentioned inside the lambda and
can be found outside of its scope is captured by reference.
Example:
int a = 0;
auto l = [&]() {
++a; // a refers to the a outside of this scope through a reference
}
l(); // execute the lambda
It is a C++11 feature and is called the lambda capture clause. In this case, the [&]
makes available to the lambda function all of the arguments to the parallel_matrix_multiply()
function by reference.
See lambda functions for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With