Re: User-define literals for std::complex.

2013-10-22 Thread Jonathan Wakely
On 20 October 2013 22:18, Ed Smith-Rowland wrote:
 On 09/27/2013 05:39 AM, Jonathan Wakely wrote:

 On 27 September 2013 05:17, Ed Smith-Rowland wrote:

 The complex user-defined literals finally passed (n3779) with the
 resolution
 to DR1473 allowing the suffix id to touch the quotes (Can't find it but I
 put it in not too long ago).

 I think it's been approved by the LWG and looks like it will go to a
 vote by the full committee, but let's wait for that to pass before
 making any changes.


 Now that this is in the working paper can we go ahead?

Yes, thanks for waiting.  The patch you posted is OK, although I think
inline constexpr on the new operators is redundant, as constexpr
functions are implicitly inline.


Re: User-define literals for std::complex.

2013-10-20 Thread Ed Smith-Rowland

On 09/27/2013 05:39 AM, Jonathan Wakely wrote:

On 27 September 2013 05:17, Ed Smith-Rowland wrote:

The complex user-defined literals finally passed (n3779) with the resolution
to DR1473 allowing the suffix id to touch the quotes (Can't find it but I
put it in not too long ago).

I think it's been approved by the LWG and looks like it will go to a
vote by the full committee, but let's wait for that to pass before
making any changes.



Now that this is in the working paper can we go ahead?




Re: User-define literals for std::complex.

2013-09-27 Thread Jonathan Wakely
On 27 September 2013 05:17, Ed Smith-Rowland wrote:

 The complex user-defined literals finally passed (n3779) with the resolution
 to DR1473 allowing the suffix id to touch the quotes (Can't find it but I
 put it in not too long ago).

I think it's been approved by the LWG and looks like it will go to a
vote by the full committee, but let's wait for that to pass before
making any changes.


User-define literals for std::complex.

2013-09-26 Thread Ed Smith-Rowland

Greetings,

The complex user-defined literals finally passed (n3779) with the 
resolution to DR1473 allowing the suffix id to touch the quotes (Can't 
find it but I put it in not too long ago).

(http://wiki.edg.com/twiki/pub/Wg21chicago2013/LibraryWorkingGroup/N3779-complex_literals.pdf)

Actually, I think allowing space between quotes and suffix ID was a mistake.

Also it looks like they are *removing* inline from the 'namespace 
literals' so that 'using std;' brings in the literals but that will be a 
later patch for all literals at once.


This has been bootstrapped and regtested on x86_64-linux.

As a general stylistic guide for the library I think I'll put
  operatorabc(...)
with no spaces.  Later.

OK?


2013-09-27  Ed Smith-Rowland  3dw...@verizon.net

Implement N3779 - User-defined Literals for std::complex,
part 2 of UDL for Standard Library Types
* include/std/complex: Add complex literal operators.
* testsuite/26_numerics/complex/literals/types.cc: New.
* testsuite/26_numerics/complex/literals/values.cc: New.

Index: include/std/complex
===
--- include/std/complex (revision 202928)
+++ include/std/complex (working copy)
@@ -1924,6 +1924,40 @@
 conj(_Tp __x)
 { return __x; }
 
+#if __cplusplus  201103L
+
+inline namespace literals {
+inline namespace complex_literals {
+
+  inline constexpr std::complexfloat
+  operatorif(long double __num)
+  { return std::complexfloat{0.0F, static_castfloat(__num)}; }
+
+  inline constexpr std::complexfloat
+  operatorif(unsigned long long __num)
+  { return std::complexfloat{0.0F, static_castfloat(__num)}; }
+
+  inline constexpr std::complexdouble
+  operatori(long double __num)
+  { return std::complexdouble{0.0, static_castdouble(__num)}; }
+
+  inline constexpr std::complexdouble
+  operatori(unsigned long long __num)
+  { return std::complexdouble{0.0, static_castdouble(__num)}; }
+
+  inline constexpr std::complexlong double
+  operatoril(long double __num)
+  { return std::complexlong double{0.0L, __num}; }
+
+  inline constexpr std::complexlong double
+  operatoril(unsigned long long __num)
+  { return std::complexlong double{0.0L, static_castlong double(__num)}; }
+
+} // inline namespace complex_literals
+} // inline namespace literals
+
+#endif // C++14
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
Index: testsuite/26_numerics/complex/literals/types.cc
===
--- testsuite/26_numerics/complex/literals/types.cc (revision 0)
+++ testsuite/26_numerics/complex/literals/types.cc (working copy)
@@ -0,0 +1,46 @@
+// { dg-options -std=c++1y }
+// { dg-do compile }
+
+// Copyright (C) 2013 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// http://www.gnu.org/licenses/.
+
+#include complex
+#include type_traits
+
+void
+test02()
+{
+  using namespace std::literals::complex_literals;
+
+  static_assert(std::is_samedecltype(1.0if), std::complexfloat::value,
+   1.0if is std::complexfloat);
+
+  static_assert(std::is_samedecltype(1if), std::complexfloat::value,
+   1if is std::complexfloat);
+
+  static_assert(std::is_samedecltype(1.0i), std::complexdouble::value,
+   1.0i is std::complexdouble);
+
+  static_assert(std::is_samedecltype(1i), std::complexdouble::value,
+   1i is std::complexdouble);
+
+  static_assert(std::is_samedecltype(1.0il), std::complexlong 
double::value,
+   1.0il is std::complexlong double);
+
+  static_assert(std::is_samedecltype(1il), std::complexlong double::value,
+   1il is std::complexlong double);
+}
Index: testsuite/26_numerics/complex/literals/values.cc
===
--- testsuite/26_numerics/complex/literals/values.cc(revision 0)
+++ testsuite/26_numerics/complex/literals/values.cc(working copy)
@@ -0,0 +1,48 @@
+// { dg-options -std=gnu++1y }
+// { dg-do run }
+
+// Copyright (C) 2013 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either