0

I recently came across this code and not certain what it is,

    CommClient.MakeHandler<nx::CommError>
(
    [&channel_stats](nx::CommError &c)
    {
        (void)c;
        channel_stats = false;
    }
);

Any one knows what this might be?

Thanks

pcbGuru
  • 1
  • 1
  • It is a lambda expression, which were introduced in C++11. See linked duplicate. That is not a particularly strange or uncommon syntax and you will probably see them in most code bases using C++11 or later. They are very helpful, replacing a lot of boilerplate that functors required pre-C++11. – user17732522 Jun 10 '22 at 18:54
  • @pcbGuru It is a function call with an argument that represents a lambda expression. – Vlad from Moscow Jun 10 '22 at 18:57
  • What is more peculiar is the `(void)c;` instruction, probably to silence an *unused parameter* warning from the compiler. But the cleanest and easiest way for that would have been to just omit the `c` argument name in the lambda. – prapin Jun 10 '22 at 21:18

0 Answers0