Lambda expressions as class template parameters

前端 未结 5 1580
星月不相逢
星月不相逢 2020-11-29 20:05

Can lambda expressions be used as class template parameters? (Note this is a very different question than this one, which asks if a lambda expression itself can be

5条回答
  •  广开言路
    2020-11-29 20:18

    You can't do this with a closure, because the state is not contained in the type.

    If your lambda is stateless (no captures), then you should be ok. In this case the lambda decays to an ordinary function pointer, which you can use as a template argument instead of some lambda type.

    gcc doesn't like it though. http://ideone.com/bHM3n

提交回复
热议问题