Questions tagged [generic-lambda]

Generic Lambda lets Lambda function parameters be set to auto to let the compiler deduce the type. This generates a lambda type with a templated operator() so that the same lambda object can be invoked with any suitable type and a type-safe function with the right parameter type will be automatically generated.

Generic Lambda lets Lambda function parameters be set to auto to let the compiler deduce the type. This generates a lambda type with a templated operator() so that the same lambda object can be invoked with any suitable type and a type-safe function with the right parameter type will be automatically generated.

More Info : https://en.wikipedia.org/wiki/C%2B%2B14#Generic_lambdas

& https://isocpp.org/wiki/faq/cpp14-language#generic-lambdas

114 questions
0
votes
1 answer

Function-scope name in generic lambda trailing return type won't compile (MSVC)

Given the following code snippet, case 1, 2, 3, and 4 compile in Visual Studio 2017 (/std:c++14), but case 5 doesn't. What's going on? int i; auto case1 = [](auto) -> decltype(i, void()) {}; int main() { int j; auto case2 = [](int) ->…
0
votes
2 answers

Extracting element with specific type from string with generic lambda

I am using c++. I have string which can contains element start with ^ and end with $. This element can be int or string. Example: "....^15$asdasd"-> 15 "...^bbbb$ccc"->"bbbb" I would like to write lambda function which would do this. If I use…
Vladimir Yanakiev
  • 1,240
  • 1
  • 16
  • 25
0
votes
1 answer

Variadic signals and generic lambdas

Is it possible to create variadic signal and connect generic lambda as slot? I mean something like (say, all definitions of involved functions are visible where needed (e.g. at points of instantiation)): #include #include…
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
0
votes
1 answer

c# Property return function - get value from lambda

I have a class with a property that returns a function. public class Demo { public Func Something { get; set; } } If I do like this Demo demo = new Demo(); string target; demo.Something = (a,b)=> { //in here `a` contains…
user2818430
  • 5,853
  • 21
  • 82
  • 148
0
votes
3 answers

find out the type of auto

I am playing with generic lambda in C++1y and I often confused by don't know what is the type of auto variable/parameter. Is any good way to find it out? Currently I am using typeid(decltype(arg)).name()) but it is not very useful. @encode gives a…
Bryan Chen
  • 45,816
  • 18
  • 112
  • 143
-1
votes
1 answer

Filter IQueryable with generic lambda Expression

I am trying to filter the DateTime? fields of my classes with a generic function. But I got the error "The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly…
-1
votes
3 answers

Should lambdas replace function templates in C++?

In C++ I can write: auto sum(const auto& x1, const auto& x2) { return x1 + x2; } int main() { cout << sum(1, 2) << endl; cout << sum(1, 2.3) << endl; cout << sum(1.4, 2.3) << endl; } Which outputs: 3 3.3 3.7 To write same code with…
Andrey Rubliov
  • 1,359
  • 2
  • 17
  • 24
-2
votes
1 answer

What [k] is in python sorting with lambda function?

I don't understand the lambda k function, and especially, what is the last [k] in this line of code? sorting_permutation = sorted(range(len(prediction_test[0:m_test])), key=lambda k: prediction_test[0:m_test][k]) I am so sorry for my English.
-3
votes
1 answer

Find item index with lambda or linkq in c#

Hi i can't speak english well forgive me if ill confuse you. in c# i have 3 String List. list_one: list of file address. list_two: list of MD5 that makes with list_one. list_three: list of MD5 that makes with list_two but in this list i collect…
RezaParsian
  • 11
  • 1
  • 5
1 2 3 4 5 6 7
8