![](/img/trans.png)
[英]Constexpr class template member function with deduced void return type?
[英]For what reason would a function with void return type be constexpr?
舉一個具體的例子,std::vector 的 push_back() 成員函數在 C++20 中變成了 constexpr。
https://en.cppreference.com/w/cpp/container/vector/push_back
constexpr
function 的要求之一是它只能調用其他constexpr
函數。
因此,這允許從其他一些constexpr
function 調用push_back
(),這實際上可能會返回一些有用的東西。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.