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

前端 未结 3 1925
臣服心动
臣服心动 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 06:09

    Section 5.1.2 paragraph 5 specifically says that you can not have default values for the parameters.

    Default arguments (8.3.6) shall not be specified in the parameter-declaration-clause of a lambda-declarator.

提交回复
热议问题