Patchwork [v3] rename packaged_task::operator bool

login
register
mail settings
Submitter Jonathan Wakely
Date Feb. 9, 2011, 11:17 p.m.
Message ID <AANLkTikjLAwkTLqDqBq15cPu3WE-JLfBOTOKLGcSq5ZT@mail.gmail.com>
Download mbox | patch
Permalink /patch/82545/
State New
Headers show

Comments

Jonathan Wakely - Feb. 9, 2011, 11:17 p.m.
The latest C++0x draft, N3225, renames packaged_task::operator bool to
packaged_task::valid, this patch makes that change.

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.

Tested x86_64-linux and committed to trunk

Patch

Index: include/std/future
===================================================================
--- include/std/future	(revision 169984)
+++ include/std/future	(working copy)
@@ -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: testsuite/30_threads/packaged_task/cons/1.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/1.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/cons/1.cc	(working copy)
@@ -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: testsuite/30_threads/packaged_task/cons/2.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/2.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/cons/2.cc	(working copy)
@@ -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: testsuite/30_threads/packaged_task/cons/move.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/move.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/cons/move.cc	(working copy)
@@ -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: testsuite/30_threads/packaged_task/cons/move_assign.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/move_assign.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/cons/move_assign.cc	(working copy)
@@ -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()
Index: testsuite/30_threads/packaged_task/cons/alloc.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/alloc.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/cons/alloc.cc	(working copy)
@@ -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: testsuite/30_threads/packaged_task/members/invoke.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/invoke.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/members/invoke.cc	(working copy)
@@ -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: testsuite/30_threads/packaged_task/members/reset.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/reset.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/members/reset.cc	(working copy)
@@ -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: testsuite/30_threads/packaged_task/members/reset2.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/reset2.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/members/reset2.cc	(working copy)
@@ -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: testsuite/30_threads/packaged_task/members/swap.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/swap.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/members/swap.cc	(working copy)
@@ -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()
Index: testsuite/30_threads/packaged_task/members/valid.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/valid.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/valid.cc	(revision 0)
@@ -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;
+}
Index: testsuite/30_threads/packaged_task/members/boolconv.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/boolconv.cc	(revision 169984)
+++ testsuite/30_threads/packaged_task/members/boolconv.cc	(working copy)
@@ -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;
-}