Why do some people prefer “T const&” over “const T&”?

后端 未结 9 1635
醉梦人生
醉梦人生 2020-12-02 12:25

So, I realize that const T& and T const& are identical and both mean a reference to a const T. In both cases, the reference is also constan

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 12:34

    If the const and & get far apart, as in

    krog::FlamBlott>
    speckleFlams( const krog::Floonage & floon, const std::map>> & obsmap);
    
    krog::FlamFinagleReport
    finagleFlams( const krog::Floonage & floon, std::map>> & obsmap)
    

    ... then it becomes easy to miss that the first 'obsmap' is a const reference and the second is not.

提交回复
热议问题