Usefulness of const (C++)

前端 未结 6 1186
眼角桃花
眼角桃花 2021-01-18 23:43

I\'m a const fiend, and I strive to make everything as const as possible.

I\'ve tried looking at various dissassembly outputs from const and non const versions of fu

6条回答
  •  灰色年华
    2021-01-19 00:21

    The primary use of const isn't to generate better code, but to protect you from yourself, ensuring that you don't accidentally change something you didn't mean to.

提交回复
热议问题