Am Fr., 16. Nov. 2018 um 18:13 Uhr schrieb Ed Smith-Rowland <3dw...@verizon.net>: > > Greetings, > > This is late but I wanted to put it out there just to finish a thing. > > It's fairly straightforward constexpr of operators and some simple > functions for std::complex. > > The only thing that jumped out was the norm function. We had this: > > struct _Norm_helper<true> > { > template<typename _Tp> > static inline _Tp _S_do_it(const complex<_Tp>& __z) > { > _Tp __res = std::abs(__z); > return __res * __res; > } > }; > > Since abs can't be made constexpr for complex since it involves sqrt (It > probably could but that's another story) I had to fall back to the x^2 + > y^2. I don't know who that will bother. This version should be faster > and I can't think of any useful trustworthy difference numerically > either in terms of accuracy of stability. > > Barring any feedback on that I'll clean it up and maybe rename my tests > from constexpr_all_the_things.cc to more_constexpr.cc ;-) > > It builds and tests cleanly on x86_64-linux.
Hmmh, according to the recent working draft the following complex functions are *not* constexpr: arg, proj So, shouldn't their new C++20-constexpr specifiers be added conditionally (In the sense of gcc extensions)? - Daniel