diff mbox

Add C++ special math functions to C++17

Message ID 56E1924E.6070703@verizon.net
State New
Headers show

Commit Message

Ed Smith-Rowland March 10, 2016, 3:27 p.m. UTC
On 03/10/2016 05:24 AM, Tobias Burnus wrote:
> Ed Smith-Rowland wrote:
>> --- include/bits/specfun.h	(svn+ssh://emsr@gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/include)	(working copy)
>> +++ svn+ssh://emsr@gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/include	(revision 234098)
>> @@ -1,6 +1,6 @@
>>   // Mathematical Special Functions for -*- C++ -*-
>>   
>> -// Copyright (C) 2006-2016 Free Software Foundation, Inc.
>> +// Copyright (C) 2006-2015 Free Software Foundation, Inc.
> The patch looks reversed ("---" for the "working copy", copyright-year change reversed etc.)
>
> Cheers,
>
> Tobias
>
Third time's a charm.
(I accidentally checked these into my branch along with a general merge 
from trunk - hence my issues)
2016-03-10  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Pull C++ Special Math into std for C++17.
	* include/bits/specfun.h: Allow special functions for C++17;
	define __cpp_lib_math_special_functions.
	* include/c_global/cmath: Allow special functions for C++17.
	* include/c_compatibility/math.h: Ditto

Comments

Jonathan Wakely March 11, 2016, 3:55 p.m. UTC | #1
The change approved in Jacksonville was to only add the special
functions to <cmath> and not <math.h>
Ed Smith-Rowland March 11, 2016, 4:31 p.m. UTC | #2
On 03/11/2016 10:55 AM, Jonathan Wakely wrote:
> The change approved in Jacksonville was to only add the special
> functions to <cmath> and not <math.h>
>
That's easy.
OK, since they changed that and the macro and made it nonconditional I 
should also drop the old-style macros __WANT_MATH_CANNEVERREMEMBER__ and 
the old-style version macro.
So, in other words, we're *not* actually supporting TR29124 (that's fine 
by me).
We can tweak the web pages.
People on C++11, C++14 can use tr1.

Did they keep the Cisms like:

   float
   foobarf(float x);

   double
   foobar(double x);

   long double
   foobarl(long double x);

I am keeping an eye out for the words of the draft github.
Maybe I'll ping Axel and Walter.

Ed
Jonathan Wakely March 11, 2016, 4:34 p.m. UTC | #3
On 11 March 2016 at 16:31, Ed Smith-Rowland <3dw4rd@verizon.net> wrote:
> On 03/11/2016 10:55 AM, Jonathan Wakely wrote:
>>
>> The change approved in Jacksonville was to only add the special
>> functions to <cmath> and not <math.h>
>>
> That's easy.
> OK, since they changed that and the macro and made it nonconditional I
> should also drop the old-style macros __WANT_MATH_CANNEVERREMEMBER__ and the
> old-style version macro.
> So, in other words, we're *not* actually supporting TR29124 (that's fine by
> me).
> We can tweak the web pages.
> People on C++11, C++14 can use tr1.

I think we can keep 29124 support for pre-C++17, and for that case
<math.h> will include the functions (when the ICANNEVERREMEMBEREITHER
macro is defined).

> Did they keep the Cisms like:
>
>   float
>   foobarf(float x);
>
>   double
>   foobar(double x);
>
>   long double
>   foobarl(long double x);

Yes, I think so.

Let's do this after gcc6 though.
diff mbox

Patch

Index: include/bits/specfun.h
===================================================================
--- include/bits/specfun.h	(svn+ssh://emsr@gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/include)	(revision 234110)
+++ include/bits/specfun.h	(.../include)	(working copy)
@@ -1,6 +1,6 @@ 
 // Mathematical Special Functions for -*- C++ -*-
 
-// Copyright (C) 2006-2015 Free Software Foundation, Inc.
+// Copyright (C) 2006-2016 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -34,15 +34,21 @@ 
 
 #include <bits/c++config.h>
 
-#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0
+#define __STDCPP_MATH_SPEC_FUNCS__ 201003L
+
+#define __cpp_lib_math_special_functions 201603L
+
+#if __cplusplus <= 201402L && __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0
 # error include <cmath> and define __STDCPP_WANT_MATH_SPEC_FUNCS__
 #endif
 
-#define __STDCPP_MATH_SPEC_FUNCS__ 201003L
-
+#include <limits>
 #include <bits/stl_algobase.h>
-#include <limits>
-#include <type_traits>
+#if __cplusplus >= 201103L
+#  include <type_traits>
+#else
+#  include <tr1/type_traits>
+#endif
 
 #include <tr1/gamma.tcc>
 #include <tr1/bessel_function.tcc>
Index: include/c_global/cmath
===================================================================
--- include/c_global/cmath	(svn+ssh://emsr@gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/include)	(revision 234110)
+++ include/c_global/cmath	(.../include)	(working copy)
@@ -1790,7 +1790,7 @@ 
 
 #endif // C++11
 
-#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
+#if __cplusplus > 201402L || __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
 #  include <bits/specfun.h>
 #endif
 
Index: include/c_compatibility/math.h
===================================================================
--- include/c_compatibility/math.h	(svn+ssh://emsr@gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/include)	(revision 234110)
+++ include/c_compatibility/math.h	(.../include)	(working copy)
@@ -111,7 +111,7 @@ 
 using std::trunc;
 #endif // C++11 && _GLIBCXX_USE_C99_MATH_TR1
 
-#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
+#if __cplusplus > 201402L || __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
 using std::assoc_laguerref;
 using std::assoc_laguerrel;
 using std::assoc_laguerre;