Why does a default argument for a lambda argument trigger a -pedantic" GCC warning?

前端 未结 3 1866
臣服心动
臣服心动 2021-02-07 05:37

I had this lambda somewhere in my code:

[](bool a, bool=true){ return !a;} }

and GCC 4.6 \"complained\" with this warning:

warn         


        
3条回答
  •  孤城傲影
    2021-02-07 05:55

    It makes no sense to have a default argument in a lambda function -- how could it ever be used? On the other hand, it does no harm, so why not allow it, after emitting a warning?

提交回复
热议问题