Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1032635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:06:30+00:00 2026-05-16T14:06:30+00:00

In C++11, is there a way to template a lambda function? Or is it

  • 0

In C++11, is there a way to template a lambda function? Or is it inherently too specific to be templated?

I understand that I can define a classic templated class/functor instead, but the question is more like: does the language allow templating lambda functions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:06:31+00:00Added an answer on May 16, 2026 at 2:06 pm

    UPDATE 2018: C++20 will come with templated and conceptualized lambdas. The feature has already been integrated into the standard draft.


    UPDATE 2014: C++14 has been released this year and now provides Polymorphic lambdas with the same syntax as in this example. Some major compilers already implement it.


    At it stands (in C++11), sadly no. Polymorphic lambdas would be excellent in terms of flexibility and power.

    The original reason they ended up being monomorphic was because of concepts. Concepts made this code situation difficult:

    template <Constraint T>
    void foo(T x)
    {
        auto bar = [](auto x){}; // imaginary syntax
    }
    

    In a constrained template you can only call other constrained templates. (Otherwise the constraints couldn’t be checked.) Can foo invoke bar(x)? What constraints does the lambda have (the parameter for it is just a template, after all)?

    Concepts weren’t ready to tackle this sort of thing; it’d require more stuff like late_check (where the concept wasn’t checked until invoked) and stuff. Simpler was just to drop it all and stick to monomorphic lambdas.

    However, with the removal of concepts from C++0x, polymorphic lambdas become a simple proposition again. However, I can’t find any proposals for it. 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to make like a template singleton class so that when
Is there a way to construct a template class that functions as both a
Is there a way to define a custom template for the no results view
Is there a way to overload base template class functions in derived classes, and
Is there a way for taking type of a template class, for example //i
Is there a way to get a specific field name from a template with
Is there direct way to do the following: template < class > struct f
Is there any way to define a global template for the Html.EditorFor helper? I
Is there a way I can get a blank MVC template for VS2008? Like
Is there any way I can insert an HTML template to existing DOMNode without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.