3 ms·
> It is expected that some corners of the language will never be available at compile time, for example I/O. So you're saying functions that have side-effects
by mehrdadn 9y ago
> It is expected that some corners of the language will never be available at compile time, for example I/O.
So you're saying functions that have side-effects like I/O can actually perform those operations at compile-time if marked with constexpr?
- Joky 9y agoNo: the purpose of constexpr is that the compiler would issue an error if a constexpr function contains such side-effects.
- mehrdadn 9y agoNo? Wouldn't it do that with a static_assert invoking the function too?
- Joky 9y agoNo sure I get the question: static_assert can only invoke constexpr functions, and constexpr functions can only call themselves other constexpr functions. Since IO functions are not constexpr, you can't call them there.