0

Using the lambda to expand an AES key, it has shown this error:

no suitable conversion function from "lambda []int (std::__1::string prekey)->int" to "int" exists

The code I am using is:

int expandedkey = [] (std::string prekey, int bit) -> int {};

This is what I found on Wikipedia describing lambdas, and I do not know that is the [capture] in it.

[capture] (args) -> return_type {body}

Standard:GNU++ 11

  • Note that the error you see is completely unrelated to the capture lists. Lambda is not an `int` type. Since typename for lambda is generated by the compiler, you need to use `auto` to deduce type of variable in which lambda will be saved. – Yksisarvinen Oct 12 '20 at 10:23
  • @Yksisarvinen Thanks. It solves my problem. – When Day Breaks Oct 12 '20 at 10:28

0 Answers0