![](/img/trans.png)
[英]constexpr std::vector and constexpr std::string in C++20
[英]How is C++20's std::vector assign constexpr?
在這里找到了我的答案。 報價,
作為 constexpr 函數並不意味着該函數在編譯時執行。 它說,該函數有可能在編譯時運行。 constexpr 函數也可以運行運行時。 如果 constexpr 函數在編譯時或運行時運行,通常是編譯器和優化級別的問題。
因此,與必須在編譯時確定的 constexpr 變量不同,對給定 constexpr 函數的一次調用可以在編譯時運行,這取決於調用情況(例如 constexpr std::vector)和另一個在運行時(例如 a非 constexpr std::vector)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.