complex: Add missing extern template declarations.
authorPaolo Carlini <pcarlini@suse.de>
Sun, 6 May 2007 18:51:10 +0000 (18:51 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 6 May 2007 18:51:10 +0000 (18:51 +0000)
2007-05-06  Paolo Carlini  <pcarlini@suse.de>

* include/std/complex: Add missing extern template declarations.
* testsuite/26_numerics/complex/complex_inserters_extractors.cc:
Move...
* testsuite/26_numerics/complex/inserters_extractors/char/1.cc:
... here.
* testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc:
New.

From-SVN: r124477

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/complex
libstdc++-v3/testsuite/26_numerics/complex/complex_inserters_extractors.cc [deleted file]
libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc [new file with mode: 0644]

index c9a436e5b1e692fcd1015ea623ffe27a315db48d..ec746b2802b6994d4b0dfffa93647552b0992e7f 100644 (file)
@@ -1,3 +1,13 @@
+2007-05-06  Paolo Carlini  <pcarlini@suse.de>
+
+       * include/std/complex: Add missing extern template declarations.
+       * testsuite/26_numerics/complex/complex_inserters_extractors.cc:
+       Move...
+       * testsuite/26_numerics/complex/inserters_extractors/char/1.cc:
+       ... here.
+       * testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc:
+       New.
+
 2007-05-06  Paolo Carlini  <pcarlini@suse.de>
 
        PR libstdc++/31834
index b91732b0c8522b9a02b3587eb7ff23a6583d8afa..04a6c69ba75363479d61cc6d25b78334c47b32c2 100644 (file)
@@ -1,6 +1,7 @@
 // The template and inlines for the -*- C++ -*- complex number classes.
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+// 2006, 2007
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -1484,6 +1485,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   complex<long double>::complex(const complex<double>& __z)
   : _M_value(__z.__rep()) { }
 
+  // Inhibit implicit instantiations for required instantiations,
+  // which are defined via explicit instantiations elsewhere.
+  // NB:  This syntax is a GNU extension.
+#if _GLIBCXX_EXTERN_TEMPLATE
+  extern template istream& operator>>(istream&, complex<float>&);
+  extern template ostream& operator<<(ostream&, const complex<float>&);
+  extern template istream& operator>>(istream&, complex<double>&);
+  extern template ostream& operator<<(ostream&, const complex<double>&);
+  extern template istream& operator>>(istream&, complex<long double>&);
+  extern template ostream& operator<<(ostream&, const complex<long double>&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  extern template wistream& operator>>(wistream&, complex<float>&);
+  extern template wostream& operator<<(wostream&, const complex<float>&);
+  extern template wistream& operator>>(wistream&, complex<double>&);
+  extern template wostream& operator<<(wostream&, const complex<double>&);
+  extern template wistream& operator>>(wistream&, complex<long double>&);
+  extern template wostream& operator<<(wostream&, const complex<long double>&);
+#endif
+#endif
+
 _GLIBCXX_END_NAMESPACE
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/complex_inserters_extractors.cc b/libstdc++-v3/testsuite/26_numerics/complex/complex_inserters_extractors.cc
deleted file mode 100644 (file)
index c9333f5..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-// 2000-02-10
-// Petter Urkedal <petter@matfys.lth.se>
-
-// Copyright (C) 2000, 2003 Free Software Foundation
-//
-// 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 2, 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 COPYING.  If not, write to the Free
-// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-
-#include <iostream>
-#include <string>
-#include <sstream>
-#include <complex>
-#include <testsuite_hooks.h>
-#include <cmath>
-
-template<typename R>
-inline bool flteq(R x, R y)
-{
-  if (x == R(0)) return y == R(0);
-  else return std::fabs(x-y) < 1e-6*std::fabs(x);
-}
-
-template<typename R>
-int
-test_good(std::string str, R x, R y)
-{
-  bool test __attribute__((unused)) = true;
-  std::complex<R> z;
-  char ch;
-  std::istringstream iss(str);
-  iss >> z >> ch;
-  VERIFY( iss.good() );
-  VERIFY( flteq(z.real(), x) );
-  VERIFY( flteq(z.imag(), y) );
-  VERIFY( ch == '#' );
-  return 0;
-}
-
-template<typename R>
-int
-test_fail(std::string str)
-{
-  bool test __attribute__((unused)) = true;
-  std::complex<R> z;
-  std::istringstream iss(str);
-  iss >> z;
-  VERIFY( iss.fail() && !iss.bad() );
-  return 0;
-}
-
-template<typename R>
-int
-testall()
-{
-  test_good<R>("(-1.1,3.7)#", -1.1, 3.7);
-  test_good<R>("(  .7e6  ,  \n-3.1)#", .7e6, -3.1);
-  test_good<R>("(\t0,-1)#", 0.0, -1.0);
-  test_good<R>("(-3.14)#", -3.14, 0.0);
-  test_good<R>("-.1#", -.1, 0.0);
-  test_good<R>(" ( -2.7e3 )#", -2.7e3, 0.0);
-  test_good<R>(" -.1#", -.1, 0.0);
-  test_fail<R>("(a,1)");
-  test_fail<R>("(,1)");
-  test_fail<R>("(1,a)");
-  test_fail<R>("(1, )");
-  test_fail<R>("|1,1)");
-  test_fail<R>("(1|1)");
-  test_fail<R>("(1,1|");
-  return 0;
-}
-
-// libstdc++/2970
-void test01()
-{
-  using namespace std;
-  bool test __attribute__((unused)) = true;
-  
-  complex<float> cf01(-1.1, -333.2);
-  stringstream ss;
-  ss << cf01;
-  string str = ss.str();
-  VERIFY( str == "(-1.1,-333.2)" );
-}
-
-// libstdc++/2985
-struct gnu_char_traits : public std::char_traits<char>
-{ };
-
-typedef std::basic_ostringstream<char, gnu_char_traits> gnu_sstream;
-template class std::basic_string<char, gnu_char_traits, std::allocator<char> >;
-
-void test02()
-{
-  bool test __attribute__((unused)) = true;
-
-  // Construct locale with specialized facets.
-  typedef gnu_sstream::__num_put_type numput_type;
-  typedef gnu_sstream::__num_get_type numget_type;
-  std::locale loc_c = std::locale::classic();
-  std::locale loc_1(loc_c, new numput_type);
-  std::locale loc_2(loc_1, new numget_type);
-  VERIFY( std::has_facet<numput_type>(loc_2) );
-  VERIFY( std::has_facet<numget_type>(loc_2) );
-
-  gnu_sstream sstr;
-  sstr.imbue(loc_2);
-
-
-  std::complex<double> x(3, 4);
-  sstr << x; 
-  VERIFY( sstr.str() == "(3,4)" );
-}
-
-int
-main()
-{
-  testall<float>();
-  testall<double>();
-  testall<long double>();
-
-  test01();
-  test02();
-
-  return 0;
-}
-
-
-
-
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc
new file mode 100644 (file)
index 0000000..9253f3a
--- /dev/null
@@ -0,0 +1,139 @@
+// 2000-02-10
+// Petter Urkedal <petter@matfys.lth.se>
+
+// Copyright (C) 2000, 2003 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <complex>
+#include <testsuite_hooks.h>
+#include <cmath>
+
+template<typename R>
+inline bool flteq(R x, R y)
+{
+  if (x == R(0)) return y == R(0);
+  else return std::fabs(x-y) < 1e-6*std::fabs(x);
+}
+
+template<typename R>
+int
+test_good(std::string str, R x, R y)
+{
+  bool test __attribute__((unused)) = true;
+  std::complex<R> z;
+  char ch;
+  std::istringstream iss(str);
+  iss >> z >> ch;
+  VERIFY( iss.good() );
+  VERIFY( flteq(z.real(), x) );
+  VERIFY( flteq(z.imag(), y) );
+  VERIFY( ch == '#' );
+  return 0;
+}
+
+template<typename R>
+int
+test_fail(std::string str)
+{
+  bool test __attribute__((unused)) = true;
+  std::complex<R> z;
+  std::istringstream iss(str);
+  iss >> z;
+  VERIFY( iss.fail() && !iss.bad() );
+  return 0;
+}
+
+template<typename R>
+int
+testall()
+{
+  test_good<R>("(-1.1,3.7)#", -1.1, 3.7);
+  test_good<R>("(  .7e6  ,  \n-3.1)#", .7e6, -3.1);
+  test_good<R>("(\t0,-1)#", 0.0, -1.0);
+  test_good<R>("(-3.14)#", -3.14, 0.0);
+  test_good<R>("-.1#", -.1, 0.0);
+  test_good<R>(" ( -2.7e3 )#", -2.7e3, 0.0);
+  test_good<R>(" -.1#", -.1, 0.0);
+  test_fail<R>("(a,1)");
+  test_fail<R>("(,1)");
+  test_fail<R>("(1,a)");
+  test_fail<R>("(1, )");
+  test_fail<R>("|1,1)");
+  test_fail<R>("(1|1)");
+  test_fail<R>("(1,1|");
+  return 0;
+}
+
+// libstdc++/2970
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  
+  complex<float> cf01(-1.1, -333.2);
+  stringstream ss;
+  ss << cf01;
+  string str = ss.str();
+  VERIFY( str == "(-1.1,-333.2)" );
+}
+
+// libstdc++/2985
+struct gnu_char_traits : public std::char_traits<char>
+{ };
+
+typedef std::basic_ostringstream<char, gnu_char_traits> gnu_sstream;
+template class std::basic_string<char, gnu_char_traits, std::allocator<char> >;
+
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+
+  // Construct locale with specialized facets.
+  typedef gnu_sstream::__num_put_type numput_type;
+  typedef gnu_sstream::__num_get_type numget_type;
+  std::locale loc_c = std::locale::classic();
+  std::locale loc_1(loc_c, new numput_type);
+  std::locale loc_2(loc_1, new numget_type);
+  VERIFY( std::has_facet<numput_type>(loc_2) );
+  VERIFY( std::has_facet<numget_type>(loc_2) );
+
+  gnu_sstream sstr;
+  sstr.imbue(loc_2);
+
+
+  std::complex<double> x(3, 4);
+  sstr << x; 
+  VERIFY( sstr.str() == "(3,4)" );
+}
+
+int
+main()
+{
+  testall<float>();
+  testall<double>();
+  testall<long double>();
+
+  test01();
+  test02();
+
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc
new file mode 100644 (file)
index 0000000..d49b2e6
--- /dev/null
@@ -0,0 +1,137 @@
+// Copyright (C) 2007 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <complex>
+#include <testsuite_hooks.h>
+#include <cmath>
+
+template<typename R>
+inline bool flteq(R x, R y)
+{
+  if (x == R(0)) return y == R(0);
+  else return std::fabs(x-y) < 1e-6*std::fabs(x);
+}
+
+template<typename R>
+int
+test_good(std::wstring str, R x, R y)
+{
+  bool test __attribute__((unused)) = true;
+  std::complex<R> z;
+  wchar_t ch;
+  std::wistringstream iss(str);
+  iss >> z >> ch;
+  VERIFY( iss.good() );
+  VERIFY( flteq(z.real(), x) );
+  VERIFY( flteq(z.imag(), y) );
+  VERIFY( ch == L'#' );
+  return 0;
+}
+
+template<typename R>
+int
+test_fail(std::wstring str)
+{
+  bool test __attribute__((unused)) = true;
+  std::complex<R> z;
+  std::wistringstream iss(str);
+  iss >> z;
+  VERIFY( iss.fail() && !iss.bad() );
+  return 0;
+}
+
+template<typename R>
+int
+testall()
+{
+  test_good<R>(L"(-1.1,3.7)#", -1.1, 3.7);
+  test_good<R>(L"(  .7e6  ,  \n-3.1)#", .7e6, -3.1);
+  test_good<R>(L"(\t0,-1)#", 0.0, -1.0);
+  test_good<R>(L"(-3.14)#", -3.14, 0.0);
+  test_good<R>(L"-.1#", -.1, 0.0);
+  test_good<R>(L" ( -2.7e3 )#", -2.7e3, 0.0);
+  test_good<R>(L" -.1#", -.1, 0.0);
+  test_fail<R>(L"(a,1)");
+  test_fail<R>(L"(,1)");
+  test_fail<R>(L"(1,a)");
+  test_fail<R>(L"(1, )");
+  test_fail<R>(L"|1,1)");
+  test_fail<R>(L"(1|1)");
+  test_fail<R>(L"(1,1|");
+  return 0;
+}
+
+// libstdc++/2970
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  
+  complex<float> cf01(-1.1, -333.2);
+  wstringstream ss;
+  ss << cf01;
+  wstring str = ss.str();
+  VERIFY( str == L"(-1.1,-333.2)" );
+}
+
+// libstdc++/2985
+struct gnu_char_traits : public std::char_traits<wchar_t>
+{ };
+
+typedef std::basic_ostringstream<wchar_t, gnu_char_traits> gnu_sstream;
+template class std::basic_string<wchar_t, gnu_char_traits,
+                                std::allocator<wchar_t> >;
+
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+
+  // Construct locale with specialized facets.
+  typedef gnu_sstream::__num_put_type numput_type;
+  typedef gnu_sstream::__num_get_type numget_type;
+  std::locale loc_c = std::locale::classic();
+  std::locale loc_1(loc_c, new numput_type);
+  std::locale loc_2(loc_1, new numget_type);
+  VERIFY( std::has_facet<numput_type>(loc_2) );
+  VERIFY( std::has_facet<numget_type>(loc_2) );
+
+  gnu_sstream sstr;
+  sstr.imbue(loc_2);
+
+
+  std::complex<double> x(3, 4);
+  sstr << x; 
+  VERIFY( sstr.str() == L"(3,4)" );
+}
+
+int
+main()
+{
+  testall<float>();
+  testall<double>();
+  testall<long double>();
+
+  test01();
+  test02();
+
+  return 0;
+}