Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Forwarding reference types for lamdas capture list

I have the following code:

template<class Callable, class ...Args>
void f(Callable t, Args &&... args)
{
    auto lambda = [t, args...](){ t(args...); };
}

int main()
{
    int x = 8;
    using callable_t = decltype(std::greater{});
    f(std::greater{}, x, 10);
}

If I understand correctly (correct me if I'm wrong), the compiler generates the following function:

void f(callable_t t, int& x, int&& y);

All I want to achieve is to make sure that in the lambda capture list, x is captured by reference and y is captured by value. How can I achieve this?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!