Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 49
    This is not true anymore in C++14. Commented Sep 10, 2014 at 11:01
  • 1
    Yeah, good point. I gave the answer why those functions can't be constexpr in c++11, because question was about c++11. Commented Sep 10, 2014 at 11:15
  • 1
    @aaronman, as Marc Glisse said, errno is not a good reason because c++ standard could provide a parallel implementation of those functions which would not modify errno. But even then constexpr implementation would'n be possible without some intrinsic compiler feature. I don't want to argue, but I think, I pointed several good reasons for that. I may be wrong of course. I'm currently writing a library which would gain a lot from constexpr math functions - that's why I'm here - but I think that there are much more problems than just 'errno'. Commented Sep 10, 2014 at 15:51
  • 3
    @AdamSzaj constexpr functions (even c++11 ones) are turing complete, so I don't see the issue you are bringing up, here is an example of contexpr sqrt I wrote a while back Commented Sep 10, 2014 at 16:02
  • 2
    Quite nice, but try awsome::sqrt(3e13) . Have you tried to implement sin, cos, tanh, or similar functions? I know that there are algorithms for such functions, but do you think that constexpr_sin(x) == sin(x)? Commented Sep 11, 2014 at 9:28