問題(Question):
這邊不是問怎麼用constexpr,而是問怎麼編譯去實現constexpr這個功能。
假設我某個code是這樣:
int main() {
(...)
const double a = 0.5;
constexpr double A = asin(a);
(...)
}
asin是在math.h裡的函式,要在link的時候才能知道asin的函數長怎樣。
那A是怎麼轉成常數的?
我能想到的是把有constexpr的檔案都先抓出來,
link後找到對應函式的指標後,把constexpr等字樣根據函式轉換成const,
然後重新編譯+link。
只是不知道實際做起來是怎樣,有人可以詳述嗎?感謝?