Re:C++17 constexpr everything, or as much as the compiler can
by Joky on Thursday December 28, 2017 @08:48PM
(#16026879)
No: the purpose of constexpr is that the compiler would issue an error if a constexpr function contains such side-effects.
Re:C++17 constexpr everything, or as much as the compiler can
by mehrdadn on Thursday December 28, 2017 @08:51PM
(#16026892)
No? Wouldn't it do that with a static_assert invoking the function too?
Re:C++17 constexpr everything, or as much as the compiler can
by Joky on Monday January 08, 2018 @11:36AM
(#16097856)
No 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.
So you're saying functions that have side-effects like I/O can actually perform those operations at compile-time if marked with constexpr?