When should I use C++14 automatic return type deduction?

前端 未结 7 2154
南笙
南笙 2020-11-28 19:05

With GCC 4.8.0 released, we have a compiler that supports automatic return type deduction, part of C++14. With -std=c++1y, I can do this:

auto          


        
7条回答
  •  无人及你
    2020-11-28 19:25

    It's got nothing to do with the simplicity of the function (as a now-deleted duplicate of this question supposed).

    Either the return type is fixed (don't use auto), or dependent in a complex way on a template parameter (use auto in most cases, paired with decltype when there are multiple return points).

提交回复
热议问题