How is this possible when the computation can be done at compile time?

Asked 2 years ago, Updated 2 years ago, 24 views

There is a content that is calculated at compile time while studying tmp or constexpr.

How can a compilation be calculated during this process when you know it's simply changing the source code to machine language?

c++

2022-09-20 19:16

1 Answers

Compilation is divided into several stages. You can think of it as a preprocessing step and switching to machine language. Usually, preprocessors (#include, #define, etc.) are processed in the preprocessing stage, and in the case of constexpr, it is calculated in the compilation stage, whether it is a constexpr variable or a function, and the value can be obtained in the compilation stage. If you have constexpr before the compiler changes to machine language, you can calculate it yourself, and if you can't calculate it, it's an error, and if you can calculate it, it's a pass.


2022-09-20 19:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.