回覆列表
  • 1 # 使用者2403650361203

    stock stock2 = stock(“fuch”, 2, 2.0); 屬於copy initialization 裡的語法形式(1)。

    其中 stock(“fuch”, 2, 2.0) 屬於 prvalue expression,所以符合文中的情況:

    First, if T is a class type and the initializer is a prvalue expression whose cv-unqualified type is the same class as T, the initializer expression itself, rather that a temporary materialized from it, is used to initialize the destination object: see copy elision

    copy elision是什麼意思,聽名字就很直觀了吧,然而這是C++17才被標準要求的語言層次上的最佳化,還得符合一些前提才會觸發這個最佳化。C++17以前做不做這個全靠編譯器的自覺,然而我所知道的幾個編譯器release模式下都有這個自覺,其中某些還提供了開關來讓你得以關閉這項最佳化。

    至於第二句,我沒找到“ 分步定義 ”的文件在哪:)

  • 中秋節和大豐收的關聯?
  • 隨便一篇議論文800字左右?