Forwarding reference types for lamdas capture list

Viewed 164

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?

0 Answers
Related