Constexpr Math Functions

aaronman picture aaronman · Jun 27, 2013 · Viewed 14.4k times · Source

So noticed from this page that none of the math functions in c++11 seems to make use of constexpr, whereas I believe all of them could be. So that leaves me with two questions, one is why did they choose not to make the functions constexpr. And two for a function like sqrt I could probably write my own constexpr, but something like sin or cos would be trickier so is there a way around it.

Answer

Sebastian Redl picture Sebastian Redl · Jun 27, 2013

Actually, because of old and annoying legacy, almost none of the math functions can be constexpr, since they all have the side-effect of setting errno on various error conditions, usually domain errors.