Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda