future (packaged_task::operator bool): Rename to...
authorJonathan Wakely <jwakely.gcc@gmail.com>
Wed, 9 Feb 2011 23:17:05 +0000 (23:17 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 9 Feb 2011 23:17:05 +0000 (23:17 +0000)
2011-02-09  Jonathan Wakely  <jwakely.gcc@gmail.com>

* include/std/future (packaged_task::operator bool): Rename to...
(packaged_task::valid): ...this.
* testsuite/30_threads/packaged_task/cons/1.cc: Adjust.
* testsuite/30_threads/packaged_task/cons/2.cc: Adjust.
* testsuite/30_threads/packaged_task/cons/move.cc: Adjust.
* testsuite/30_threads/packaged_task/cons/move_assign.cc: Adjust.
* testsuite/30_threads/packaged_task/cons/alloc.cc: Adjust.
* testsuite/30_threads/packaged_task/members/invoke.cc: Adjust.
* testsuite/30_threads/packaged_task/members/reset.cc: Adjust.
* testsuite/30_threads/packaged_task/members/reset2.cc: Adjust.
* testsuite/30_threads/packaged_task/members/swap.cc: Adjust.
* testsuite/30_threads/packaged_task/members/boolconv.cc: Remove.
* testsuite/30_threads/packaged_task/members/valid.cc: Add.

From-SVN: r169988

13 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/future
libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc
libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc
libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc
libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc
libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc
libstdc++-v3/testsuite/30_threads/packaged_task/members/boolconv.cc [deleted file]
libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc
libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc
libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc
libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc
libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc [new file with mode: 0644]

index eec7703cb90e57844e37b216c77ebe6056295a61..243659f02086f4fe2667c58c7f58556bdb8ea013 100644 (file)
@@ -1,3 +1,19 @@
+2011-02-09  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       * include/std/future (packaged_task::operator bool): Rename to...
+       (packaged_task::valid): ...this.
+       * testsuite/30_threads/packaged_task/cons/1.cc: Adjust.
+       * testsuite/30_threads/packaged_task/cons/2.cc: Adjust.
+       * testsuite/30_threads/packaged_task/cons/move.cc: Adjust.
+       * testsuite/30_threads/packaged_task/cons/move_assign.cc: Adjust.
+       * testsuite/30_threads/packaged_task/cons/alloc.cc: Adjust.
+       * testsuite/30_threads/packaged_task/members/invoke.cc: Adjust.
+       * testsuite/30_threads/packaged_task/members/reset.cc: Adjust.
+       * testsuite/30_threads/packaged_task/members/reset2.cc: Adjust.
+       * testsuite/30_threads/packaged_task/members/swap.cc: Adjust.
+       * testsuite/30_threads/packaged_task/members/boolconv.cc: Remove.
+       * testsuite/30_threads/packaged_task/members/valid.cc: Add.
+
 2011-02-09  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * doc/xml/manual/io.xml: Fix typo.
index f268d4ab06a90ef4b4a3592203403b2eed4104ec..e32b2a073dd0c432a99bf0934f3ed86f17d60a23 100644 (file)
@@ -1,6 +1,6 @@
 // <future> -*- C++ -*-
 
-// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -1250,7 +1250,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       swap(packaged_task& __other)
       { _M_state.swap(__other._M_state); }
 
-      explicit operator bool() const { return static_cast<bool>(_M_state); }
+      bool
+      valid() const
+      { return static_cast<bool>(_M_state); }
 
       // Result retrieval
       future<_Res>
index a2414333e220bc51e48f518ebf3bc6d48126ba0c..b6ea492536a8b3b05f53564572c533ac091111ab 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -35,15 +35,15 @@ void test01()
   using namespace __gnu_test;
 
   packaged_task<int ()> p1;
-  VERIFY( !static_cast<bool>(p1) );
+  VERIFY( !p1.valid() );
   packaged_task<int& ()> p2;
-  VERIFY( !static_cast<bool>(p2) );
+  VERIFY( !p2.valid() );
   packaged_task<void ()> p3;
-  VERIFY( !static_cast<bool>(p3) );
+  VERIFY( !p3.valid() );
   packaged_task<ClassType ()> p4;
-  VERIFY( !static_cast<bool>(p4) );
+  VERIFY( !p4.valid() );
   packaged_task<AbstractClass& (int)> p5;
-  VERIFY( !static_cast<bool>(p5) );
+  VERIFY( !p5.valid() );
 }
 
 int main()
index 98f5de73c4db78dff1f4c2235f340adf979ccf17..9dc9757902d51a5dc85d9625167c349a2f241684 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -46,15 +46,15 @@ void test01()
   using std::packaged_task;
 
   packaged_task<int ()> p1(f1);
-  VERIFY( static_cast<bool>(p1) );
+  VERIFY( p1.valid() );
   packaged_task<int& ()> p2(f2);
-  VERIFY( static_cast<bool>(p2) );
+  VERIFY( p2.valid() );
   packaged_task<void ()> p3(f3);
-  VERIFY( static_cast<bool>(p3) );
+  VERIFY( p3.valid() );
   packaged_task<ClassType ()> p4(f4);
-  VERIFY( static_cast<bool>(p4) );
+  VERIFY( p4.valid() );
   packaged_task<AbstractClass& (int)> p5(f5);
-  VERIFY( static_cast<bool>(p5) );
+  VERIFY( p5.valid() );
 }
 
 int main()
index 99253cde7d3d382e19f48897244475b5ac01087e..531871417074568966dbb0b7fd925bc9a46bd1ef 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011 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
@@ -40,7 +40,7 @@ void test01()
   uneq_allocator<char> alloc(99);
 
   packaged_task<int ()> p1(allocator_arg, alloc, f);
-  VERIFY( static_cast<bool>(p1) );
+  VERIFY( p1.valid() );
   p1();
   VERIFY( p1.get_future().get() == 5 );
 }
index 5335db39949415a1378ddce25d2a28d77aaa5169..599caf9092e0bbd8434be670fb4ef941f50b2cf1 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -37,8 +37,8 @@ void test01()
   // move
   packaged_task<int()> p1(f1);
   packaged_task<int()> p2(std::move(p1));
-  VERIFY( !static_cast<bool>(p1) );
-  VERIFY( static_cast<bool>(p2) );
+  VERIFY( !p1.valid() );
+  VERIFY( p2.valid() );
 }
 
 int main()
index c23e5e3b72b9d7e2afa3e21226d27e16749c4710..1c5dfc3b9b29f82d5a881aef00db51d703e02213 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2011 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
@@ -37,8 +37,8 @@ void test01()
   std::packaged_task<int()> p1;
   std::packaged_task<int()> p2(gen);
   p1 = std::move(p2);
-  VERIFY( static_cast<bool>(p1) );
-  VERIFY( !static_cast<bool>(p2) );
+  VERIFY( p1.valid() );
+  VERIFY( !p2.valid() );
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/boolconv.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/boolconv.cc
deleted file mode 100644 (file)
index c332b85..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
-// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
-// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
-// { dg-require-cstdint "" }
-// { dg-require-gthreads "" }
-// { dg-require-atomic-builtins "" }
-
-// Copyright (C) 2009 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 <future>
-#include <testsuite_hooks.h>
-
-int zero() { return 0; }
-
-void test01()
-{
-  bool test __attribute__((unused)) = true;
-
-  std::packaged_task<int()> p1;
-  VERIFY( !static_cast<bool>(p1) );
-
-  std::packaged_task<int()> p2(zero);
-  VERIFY( static_cast<bool>(p2) );
-}
-
-int main()
-{
-  test01();
-  return 0;
-}
index cce7b54e269cbf73c5a045e758ab436c6c4bfe8b..238568fe3db9c8e3ff385901bc6b8c3cc25c1337 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -38,7 +38,7 @@ void test01()
 
   p1();
 
-  VERIFY( static_cast<bool>(p1) );
+  VERIFY( p1.valid() );
   VERIFY( f1.get() == 0 );
 }
 
index a126c3ace88daaeabbe1239ccd1092b16fc93f2b..01a06d6a3c2d715e9af9f22fedf237bcf5029e70 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009. 2010, 2011 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
@@ -39,7 +39,7 @@ void test01()
   future<int> f1 = p1.get_future();
 
   p1.reset();
-  VERIFY( static_cast<bool>(p1) );
+  VERIFY( p1.valid() );
 
   future<int> f2 = p1.get_future();
 
index e38d047866221a7721f0541a1a19e5f902654115..2fac36637764bfcd256af802fc9bc6dd0d84ca5d 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -39,7 +39,7 @@ void test01()
   p1();
   p1.reset();
 
-  VERIFY( static_cast<bool>(p1) );
+  VERIFY( p1.valid() );
   VERIFY( f1.get() == 0 );
 
   std::future<int> f2 = p1.get_future();
index ced2a00529a9e292d95f1e80bd1d9ece0a65f9bb..9055d9837f817752e4b76a9e1f978f973cdfaa1c 100644 (file)
@@ -6,7 +6,7 @@
 // { dg-require-gthreads "" }
 // { dg-require-atomic-builtins "" }
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011 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
@@ -35,11 +35,11 @@ void test01()
 
   std::packaged_task<int()> p1(zero);
   std::packaged_task<int()> p2;
-  VERIFY( static_cast<bool>(p1) );
-  VERIFY( !static_cast<bool>(p2) );
+  VERIFY( p1.valid() );
+  VERIFY( !p2.valid() );
   p1.swap(p2);
-  VERIFY( !static_cast<bool>(p1) );
-  VERIFY( static_cast<bool>(p2) );
+  VERIFY( !p1.valid() );
+  VERIFY( p2.valid() );
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc
new file mode 100644 (file)
index 0000000..d7f1ed1
--- /dev/null
@@ -0,0 +1,47 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// Copyright (C) 2011 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 <future>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::packaged_task<int()> p1;
+  VERIFY( !p1.valid() );
+
+  std::packaged_task<int()> p2(zero);
+  VERIFY( p2.valid() );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}