[PATCH] D43159: Modernize: Use nullptr more.

2020-11-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 307398.
ldionne added a comment.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Rebase onto master


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159

Files:
  libcxx/include/__locale
  libcxx/include/__sso_allocator
  libcxx/include/__string
  libcxx/include/__threading_support
  libcxx/include/algorithm
  libcxx/include/bitset
  libcxx/include/chrono
  libcxx/include/fstream
  libcxx/include/functional
  libcxx/include/ios
  libcxx/include/istream
  libcxx/include/iterator
  libcxx/include/locale
  libcxx/include/memory
  libcxx/include/regex
  libcxx/include/sstream
  libcxx/include/streambuf
  libcxx/include/string
  libcxx/include/strstream
  libcxx/include/system_error
  libcxx/include/valarray
  libcxx/src/new.cpp

Index: libcxx/src/new.cpp
===
--- libcxx/src/new.cpp
+++ libcxx/src/new.cpp
@@ -64,7 +64,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -85,7 +85,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -111,7 +111,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -207,7 +207,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -233,7 +233,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: libcxx/include/valarray
===
--- libcxx/include/valarray
+++ libcxx/include/valarray
@@ -802,7 +802,7 @@
 public:
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
-valarray() : __begin_(0), __end_(0) {}
+valarray() : __begin_(nullptr), __end_(nullptr) {}
 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
@@ -2750,8 +2750,8 @@
 template 
 inline
 valarray<_Tp>::valarray(size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2776,16 +2776,16 @@
 template 
 inline
 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 resize(__n, __x);
 }
 
 template 
 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2809,8 +2809,8 @@
 
 template 
 valarray<_Tp>::valarray(const valarray& __v)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__v.size())
 {
@@ -2845,8 +2845,8 @@
 
 template 
 valarray<_Tp>::valarray(initializer_list __il)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __il.size();
 if (__n)
@@ -2874,8 +2874,8 @@
 
 template 
 valarray<_Tp>::valarray(const slice_array& __sa)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __sa.__size_;
 if (__n)
@@ -2901,8 +2901,8 @@
 
 template 
 valarray<_Tp>::valarray(const gslice_array& __ga)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ga.__1d_.size();
 if (__n)
@@ -2930,8 +2930,8 @@
 
 template 
 valarray<_Tp>::valarray(const mask_array& __ma)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ma.__1d_.size();
 if (__n)
@@ -2959,8 +2959,8 @@
 
 template 
 valarray<_Tp>::valarray(const indirect_array& __ia)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ia.__1d_.size();
 if (__n)
Index: libcxx/include/system_error
===
--- libcxx/include/system_error
+++ libcxx/include/system_error
@@ -253,7 +253,7 @@
 template 
 _LIBCPP_INLINE_VISIBILITY
 error_condition(_Ep __e,
-  typename enable_if::value>::type* = 0
+  typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = make_error_condition(__e);}
 
@@ -325,7 +325,7 @@
 template 
 

[PATCH] D43159: Modernize: Use nullptr more.

2020-03-25 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Ping -- is there still interest in moving forward with this? If so, please 
address the comments and update the patch, otherwise you can abandon the 
revision to clean up the libc++ review queue.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-04 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: include/__threading_support:323
 bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
-  return *__t == 0;
+  return *__t == nullptr;
 }

mclow.lists wrote:
> mclow.lists wrote:
> > This one is wrong.
> `__libcpp_thread_t` is an alias for an operating-system specific type.
> On Mac OS, it is a pointer to some Darwin-specific type.
> On Ubuntu, it is a `const unsigned long`.
> 
> You can't compare it to `nullptr`.
> 
I think the comparison should be `*__t == __libcpp_thread_t()`.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/__threading_support:323
 bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
-  return *__t == 0;
+  return *__t == nullptr;
 }

mclow.lists wrote:
> This one is wrong.
`__libcpp_thread_t` is an alias for an operating-system specific type.
On Mac OS, it is a pointer to some Darwin-specific type.
On Ubuntu, it is a `const unsigned long`.

You can't compare it to `nullptr`.



Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-03 Thread Louis Dionne via Phabricator via cfe-commits
ldionne requested changes to this revision.
ldionne added a comment.

I agree with Marshall's requests.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/algorithm:4431
 value_type* __p = __buff;
-for (_BidirectionalIterator __i = __first; __i != __middle; 
__d.__incr((value_type*)0), (void) ++__i, ++__p)
+for (_BidirectionalIterator __i = __first; __i != __middle; 
__d.__incr((value_type*)nullptr), (void) ++__i, ++__p)
 ::new(__p) value_type(_VSTD::move(*__i));

I'm not really a fan of casting `nullptr` to a `value_type *`. This change 
doesn't seem to add anything to the code; it's just longer. 

The call to `__incr` doesn't use the pointer at all. Maybe a better approach is 
to change 
```
template 
_LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT
{__incr(integral_constant::value>());}
```

to:
```
template 
_LIBCPP_INLINE_VISIBILITY void __incr() _NOEXCEPT
{__incr(integral_constant::value>());}
```

and remove the `nullptr`s from the calls in ``
Alternately, add an overload of `__incr` that takes a `nullptr_t`.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In ``, you missed a couple of `(value_type*)0`. Line 3356, 3369, 
3486 and 3499.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists requested changes to this revision.
mclow.lists added a comment.
This revision now requires changes to proceed.

Did you try to build libc++ or run the tests before submitting this?




Comment at: include/__threading_support:323
 bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
-  return *__t == 0;
+  return *__t == nullptr;
 }

This one is wrong.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-02 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: dexonsmith.

I'm fine with this given what the author said about `nullptr` already being 
used in those headers.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-01 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem added a comment.

In addition to my previous explanation for the concerns about using `nullptr` 
more ... it should be noted that many of these files already use `nullptr`.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-07-01 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem updated this revision to Diff 207356.
brucem added a comment.

Updating to current master.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159

Files:
  include/__locale
  include/__sso_allocator
  include/__string
  include/__threading_support
  include/algorithm
  include/bitset
  include/chrono
  include/fstream
  include/functional
  include/ios
  include/istream
  include/iterator
  include/locale
  include/memory
  include/regex
  include/sstream
  include/streambuf
  include/string
  include/strstream
  include/system_error
  include/valarray
  src/new.cpp

Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -64,7 +64,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -85,7 +85,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -111,7 +111,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -206,7 +206,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -232,7 +232,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -802,7 +802,7 @@
 public:
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
-valarray() : __begin_(0), __end_(0) {}
+valarray() : __begin_(nullptr), __end_(nullptr) {}
 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
@@ -2764,8 +2764,8 @@
 template 
 inline
 valarray<_Tp>::valarray(size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2791,16 +2791,16 @@
 template 
 inline
 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 resize(__n, __x);
 }
 
 template 
 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2825,8 +2825,8 @@
 
 template 
 valarray<_Tp>::valarray(const valarray& __v)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__v.size())
 {
@@ -2862,8 +2862,8 @@
 
 template 
 valarray<_Tp>::valarray(initializer_list __il)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __il.size();
 if (__n)
@@ -2892,8 +2892,8 @@
 
 template 
 valarray<_Tp>::valarray(const slice_array& __sa)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __sa.__size_;
 if (__n)
@@ -2920,8 +2920,8 @@
 
 template 
 valarray<_Tp>::valarray(const gslice_array& __ga)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ga.__1d_.size();
 if (__n)
@@ -2950,8 +2950,8 @@
 
 template 
 valarray<_Tp>::valarray(const mask_array& __ma)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ma.__1d_.size();
 if (__n)
@@ -2980,8 +2980,8 @@
 
 template 
 valarray<_Tp>::valarray(const indirect_array& __ia)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ia.__1d_.size();
 if (__n)
Index: include/system_error
===
--- include/system_error
+++ include/system_error
@@ -253,7 +253,7 @@
 template 
 _LIBCPP_INLINE_VISIBILITY
 error_condition(_Ep __e,
-  typename enable_if::value>::type* = 0
+  typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = make_error_condition(__e);}
 
@@ -325,7 +325,7 @@
 template 
 _LIBCPP_INLINE_VISIBILITY
 error_code(_Ep __e,
-   typename enable_if::value>::type* = 0
+   typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = 

[PATCH] D43159: Modernize: Use nullptr more.

2019-06-01 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem marked an inline comment as done.
brucem added a comment.

In D43159#1526215 , @mclow.lists wrote:

> What was the result of testing with `-std=c++98` and/or `-std=gnu++98` ?
>  The code changes look fine; but as @Ericwf said


It seems to work for me in `-std=c++98` ...

I responded to the point that @Ericwf made before ... the `__nullptr` header is 
included by the wrapper around `stddef.h` ... and these aren't the first / only 
usages of `nullptr` in the headers.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-06-01 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem marked 2 inline comments as done.
brucem added inline comments.



Comment at: include/memory:1259
 template  static __two __test(...);
 template  static char __test(typename _Xp::template 
rebind<_Up>::other* = 0);
 public:

zoecarver wrote:
> This could be `nullptr` too. 
This pointed out a number of things that could be fixed, so did  that and 
updated.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-06-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: include/memory:1259
 template  static __two __test(...);
 template  static char __test(typename _Xp::template 
rebind<_Up>::other* = 0);
 public:

This could be `nullptr` too. 


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-06-01 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem updated this revision to Diff 202555.
brucem added a comment.

Remove CMakeLists.txt change.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159

Files:
  include/__functional_base
  include/__locale
  include/__sso_allocator
  include/__string
  include/__threading_support
  include/algorithm
  include/bitset
  include/chrono
  include/deque
  include/fstream
  include/functional
  include/ios
  include/istream
  include/iterator
  include/locale
  include/memory
  include/regex
  include/sstream
  include/streambuf
  include/string
  include/strstream
  include/system_error
  include/type_traits
  include/valarray
  src/ios.cpp
  src/locale.cpp
  src/new.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -84,7 +84,7 @@
 unsigned n;
 int mib[2] = {CTL_HW, HW_NCPU};
 std::size_t s = sizeof(n);
-sysctl(mib, 2, , , 0, 0);
+sysctl(mib, 2, , , nullptr, 0);
 return n;
 #elif defined(_SC_NPROCESSORS_ONLN)
 long result = sysconf(_SC_NPROCESSORS_ONLN);
Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -64,7 +64,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -85,7 +85,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -111,7 +111,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -206,7 +206,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -232,7 +232,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -47,7 +47,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 struct __libcpp_unique_locale {
-  __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {}
+  __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, nullptr)) {}
 
   ~__libcpp_unique_locale() {
 if (__loc_)
@@ -536,7 +536,7 @@
 
 locale::locale(const char* name)
 : __locale_(name ? new __imp(name)
- : (__throw_runtime_error("locale constructed with null"), (__imp*)0))
+ : (__throw_runtime_error("locale constructed with null"), nullptr))
 {
 __locale_->__add_shared();
 }
@@ -549,7 +549,7 @@
 
 locale::locale(const locale& other, const char* name, category c)
 : __locale_(name ? new __imp(*other.__locale_, name, c)
- : (__throw_runtime_error("locale constructed with null"), (__imp*)0))
+ : (__throw_runtime_error("locale constructed with null"), nullptr))
 {
 __locale_->__add_shared();
 }
@@ -664,18 +664,18 @@
 
 collate_byname::collate_byname(const char* n, size_t refs)
 : collate(refs),
-  __l(newlocale(LC_ALL_MASK, n, 0))
+  __l(newlocale(LC_ALL_MASK, n, nullptr))
 {
-if (__l == 0)
+if (__l == nullptr)
 __throw_runtime_error("collate_byname::collate_byname"
 " failed to construct for " + string(n));
 }
 
 collate_byname::collate_byname(const string& name, size_t refs)
 : collate(refs),
-  __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+  __l(newlocale(LC_ALL_MASK, name.c_str(), nullptr))
 {
-if (__l == 0)
+if (__l == nullptr)
 __throw_runtime_error("collate_byname::collate_byname"
 " failed to construct for " + name);
 }
@@ -703,7 +703,7 @@
 collate_byname::do_transform(const char_type* lo, const char_type* hi) const
 {
 const string_type in(lo, hi);
-string_type out(strxfrm_l(0, in.c_str(), 0, __l), char());
+string_type out(strxfrm_l(nullptr, in.c_str(), 0, __l), char());
 strxfrm_l(const_cast(out.c_str()), in.c_str(), out.size()+1, __l);
 return out;
 }
@@ -712,18 +712,18 @@
 
 collate_byname::collate_byname(const char* n, size_t refs)
 : collate(refs),
-  __l(newlocale(LC_ALL_MASK, n, 0))
+  __l(newlocale(LC_ALL_MASK, n, nullptr))
 {
-if (__l == 0)
+if (__l == nullptr)
 __throw_runtime_error("collate_byname::collate_byname(size_t refs)"
 " failed to construct for " + string(n));
 }
 
 collate_byname::collate_byname(const 

[PATCH] D43159: Modernize: Use nullptr more.

2019-06-01 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem updated this revision to Diff 202554.
brucem added a comment.
Herald added a subscriber: mgorny.

Updated to current master and added more nullptr usage.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159

Files:
  CMakeLists.txt
  include/__functional_base
  include/__locale
  include/__sso_allocator
  include/__string
  include/__threading_support
  include/algorithm
  include/bitset
  include/chrono
  include/deque
  include/fstream
  include/functional
  include/ios
  include/istream
  include/iterator
  include/locale
  include/memory
  include/regex
  include/sstream
  include/streambuf
  include/string
  include/strstream
  include/system_error
  include/type_traits
  include/valarray
  src/ios.cpp
  src/locale.cpp
  src/new.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -84,7 +84,7 @@
 unsigned n;
 int mib[2] = {CTL_HW, HW_NCPU};
 std::size_t s = sizeof(n);
-sysctl(mib, 2, , , 0, 0);
+sysctl(mib, 2, , , nullptr, 0);
 return n;
 #elif defined(_SC_NPROCESSORS_ONLN)
 long result = sysconf(_SC_NPROCESSORS_ONLN);
Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -64,7 +64,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -85,7 +85,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -111,7 +111,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -206,7 +206,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -232,7 +232,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -47,7 +47,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 struct __libcpp_unique_locale {
-  __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {}
+  __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, nullptr)) {}
 
   ~__libcpp_unique_locale() {
 if (__loc_)
@@ -536,7 +536,7 @@
 
 locale::locale(const char* name)
 : __locale_(name ? new __imp(name)
- : (__throw_runtime_error("locale constructed with null"), (__imp*)0))
+ : (__throw_runtime_error("locale constructed with null"), nullptr))
 {
 __locale_->__add_shared();
 }
@@ -549,7 +549,7 @@
 
 locale::locale(const locale& other, const char* name, category c)
 : __locale_(name ? new __imp(*other.__locale_, name, c)
- : (__throw_runtime_error("locale constructed with null"), (__imp*)0))
+ : (__throw_runtime_error("locale constructed with null"), nullptr))
 {
 __locale_->__add_shared();
 }
@@ -664,18 +664,18 @@
 
 collate_byname::collate_byname(const char* n, size_t refs)
 : collate(refs),
-  __l(newlocale(LC_ALL_MASK, n, 0))
+  __l(newlocale(LC_ALL_MASK, n, nullptr))
 {
-if (__l == 0)
+if (__l == nullptr)
 __throw_runtime_error("collate_byname::collate_byname"
 " failed to construct for " + string(n));
 }
 
 collate_byname::collate_byname(const string& name, size_t refs)
 : collate(refs),
-  __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+  __l(newlocale(LC_ALL_MASK, name.c_str(), nullptr))
 {
-if (__l == 0)
+if (__l == nullptr)
 __throw_runtime_error("collate_byname::collate_byname"
 " failed to construct for " + name);
 }
@@ -703,7 +703,7 @@
 collate_byname::do_transform(const char_type* lo, const char_type* hi) const
 {
 const string_type in(lo, hi);
-string_type out(strxfrm_l(0, in.c_str(), 0, __l), char());
+string_type out(strxfrm_l(nullptr, in.c_str(), 0, __l), char());
 strxfrm_l(const_cast(out.c_str()), in.c_str(), out.size()+1, __l);
 return out;
 }
@@ -712,18 +712,18 @@
 
 collate_byname::collate_byname(const char* n, size_t refs)
 : collate(refs),
-  __l(newlocale(LC_ALL_MASK, n, 0))
+  __l(newlocale(LC_ALL_MASK, n, nullptr))
 {
-if (__l == 0)
+if (__l == nullptr)
 __throw_runtime_error("collate_byname::collate_byname(size_t refs)"
 " 

[PATCH] D43159: Modernize: Use nullptr more.

2019-06-01 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In D43159#1526170 , @brucem wrote:

> Can we revive this review? I'd still like to land this ...


What was the result of testing with `-std=c++98` and/or `-std=gnu++98` ?
The code changes look fine; but as @Ericwf said


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2019-06-01 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem added a comment.
Herald added subscribers: libcxx-commits, jfb, ldionne, christof.

Can we revive this review? I'd still like to land this ...


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2018-02-12 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem added a comment.

In https://reviews.llvm.org/D43159#1004617, @jroelofs wrote:

> Is it worth adding `-Werror=zero-as-null-pointer-constant` to the build?


I'll look at this as a follow up.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2018-02-12 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem added a comment.

In https://reviews.llvm.org/D43159#1004639, @dim wrote:

> In https://reviews.llvm.org/D43159#1004625, @EricWF wrote:
>
> > So my main concern with this patch is that `nullptr` is actually  
> > `#defined`'ed in C++03 mode. That definition comes from the `__nullptr` 
> > header, and therefore we would need to add that header to each include 
> > which uses it. Which kind of sucks.
>
>
> Indeed, but isn't `nullptr` used in many headers already?  And as far as I 
> can see, none of those includes <__nullptr> explicitly, so the definition 
> must come from some transitive include.


It is handled in the wrapper around `stddef.h` so it all should just work.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2018-02-12 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem updated this revision to Diff 133996.
brucem added a comment.

Addressed minor issues.

- Addressed missing __end_ initialization from valarray.
- Removed cast that was no longer needed.
- Added nullptr usage to include/regex.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159

Files:
  include/__locale
  include/__sso_allocator
  include/__string
  include/__threading_support
  include/algorithm
  include/bitset
  include/chrono
  include/fstream
  include/functional
  include/ios
  include/istream
  include/iterator
  include/locale
  include/memory
  include/regex
  include/sstream
  include/streambuf
  include/string
  include/strstream
  include/system_error
  include/valarray
  src/new.cpp

Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -71,7 +71,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -92,7 +92,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -118,7 +118,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -214,7 +214,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -240,7 +240,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -802,7 +802,7 @@
 public:
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
-valarray() : __begin_(0), __end_(0) {}
+valarray() : __begin_(nullptr), __end_(nullptr) {}
 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
@@ -2750,8 +2750,8 @@
 template 
 inline
 valarray<_Tp>::valarray(size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2776,16 +2776,16 @@
 template 
 inline
 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 resize(__n, __x);
 }
 
 template 
 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2809,8 +2809,8 @@
 
 template 
 valarray<_Tp>::valarray(const valarray& __v)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__v.size())
 {
@@ -2845,8 +2845,8 @@
 
 template 
 valarray<_Tp>::valarray(initializer_list __il)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __il.size();
 if (__n)
@@ -2873,8 +2873,8 @@
 
 template 
 valarray<_Tp>::valarray(const slice_array& __sa)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __sa.__size_;
 if (__n)
@@ -2899,8 +2899,8 @@
 
 template 
 valarray<_Tp>::valarray(const gslice_array& __ga)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __ga.__1d_.size();
 if (__n)
@@ -2928,8 +2928,8 @@
 
 template 
 valarray<_Tp>::valarray(const mask_array& __ma)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __ma.__1d_.size();
 if (__n)
@@ -2957,8 +2957,8 @@
 
 template 
 valarray<_Tp>::valarray(const indirect_array& __ia)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __ia.__1d_.size();
 if (__n)
Index: include/system_error
===
--- include/system_error
+++ include/system_error
@@ -440,7 +440,7 @@
 template 
 _LIBCPP_ALWAYS_INLINE
 error_condition(_Ep __e,
-  typename enable_if::value>::type* = 0
+  typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = make_error_condition(__e);}
 
@@ -512,7 +512,7 @@
 template 
 _LIBCPP_ALWAYS_INLINE
 error_code(_Ep __e,
-   typename enable_if::value>::type* = 0
+   typename 

[PATCH] D43159: Modernize: Use nullptr more.

2018-02-11 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In https://reviews.llvm.org/D43159#1004625, @EricWF wrote:

> So my main concern with this patch is that `nullptr` is actually  
> `#defined`'ed in C++03 mode. That definition comes from the `__nullptr` 
> header, and therefore we would need to add that header to each include which 
> uses it. Which kind of sucks.


Indeed, but isn't `nullptr` used in many headers already?  And as far as I can 
see, none of those includes <__nullptr> explicitly, so the definition must come 
from some transitive include.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2018-02-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

So my main concern with this patch is that `nullptr` is actually  `#defined`'ed 
in C++03 mode. That definition comes from the `__nullptr` header, and therefore 
we would need to add that header to each include which uses it. Which kind of 
sucks.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2018-02-11 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Is it worth adding `-Werror=zero-as-null-pointer-constant` to the build?


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2018-02-11 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

LGTM minus a few nits, though it would be nice if you can verify that all the 
changed headers still compile in `-std=c++98` and/or `-std=gnu++98` mode.




Comment at: include/functional:1573
 return &__f_.first();
-return (const void*)0;
+return (const void*)nullptr;
 }

The cast can be removed now.



Comment at: include/valarray:805
 _LIBCPP_INLINE_VISIBILITY
-valarray() : __begin_(0), __end_(0) {}
+valarray() : __begin_(nullptr), __end_(0) {}
 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY

Missed `__end` here?


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2018-02-10 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem updated this revision to Diff 133778.
brucem added a comment.

More nullptr usage.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43159

Files:
  include/__locale
  include/__sso_allocator
  include/__string
  include/__threading_support
  include/algorithm
  include/bitset
  include/chrono
  include/fstream
  include/functional
  include/ios
  include/istream
  include/iterator
  include/locale
  include/memory
  include/sstream
  include/streambuf
  include/string
  include/strstream
  include/system_error
  include/valarray
  src/new.cpp

Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -71,7 +71,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -92,7 +92,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -118,7 +118,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -214,7 +214,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -240,7 +240,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -802,7 +802,7 @@
 public:
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
-valarray() : __begin_(0), __end_(0) {}
+valarray() : __begin_(nullptr), __end_(0) {}
 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
@@ -2750,8 +2750,8 @@
 template 
 inline
 valarray<_Tp>::valarray(size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2776,16 +2776,16 @@
 template 
 inline
 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 resize(__n, __x);
 }
 
 template 
 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2809,8 +2809,8 @@
 
 template 
 valarray<_Tp>::valarray(const valarray& __v)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__v.size())
 {
@@ -2845,8 +2845,8 @@
 
 template 
 valarray<_Tp>::valarray(initializer_list __il)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __il.size();
 if (__n)
@@ -2873,8 +2873,8 @@
 
 template 
 valarray<_Tp>::valarray(const slice_array& __sa)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __sa.__size_;
 if (__n)
@@ -2899,8 +2899,8 @@
 
 template 
 valarray<_Tp>::valarray(const gslice_array& __ga)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __ga.__1d_.size();
 if (__n)
@@ -2928,8 +2928,8 @@
 
 template 
 valarray<_Tp>::valarray(const mask_array& __ma)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __ma.__1d_.size();
 if (__n)
@@ -2957,8 +2957,8 @@
 
 template 
 valarray<_Tp>::valarray(const indirect_array& __ia)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 size_t __n = __ia.__1d_.size();
 if (__n)
Index: include/system_error
===
--- include/system_error
+++ include/system_error
@@ -440,7 +440,7 @@
 template 
 _LIBCPP_ALWAYS_INLINE
 error_condition(_Ep __e,
-  typename enable_if::value>::type* = 0
+  typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = make_error_condition(__e);}
 
@@ -512,7 +512,7 @@
 template 
 _LIBCPP_ALWAYS_INLINE
 error_code(_Ep __e,
-   typename enable_if::value>::type* = 0
+   typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = make_error_code(__e);}
 

[PATCH] D43159: Modernize: Use nullptr more.

2018-02-10 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem created this revision.
brucem added reviewers: mclow.lists, EricWF.

Repository:
  rCXX libc++

https://reviews.llvm.org/D43159

Files:
  include/__locale
  include/__string
  include/__threading_support
  include/algorithm
  include/bitset
  include/chrono
  include/fstream
  include/functional
  include/ios
  include/iterator
  include/locale
  include/memory
  include/sstream
  include/string
  include/system_error

Index: include/system_error
===
--- include/system_error
+++ include/system_error
@@ -512,7 +512,7 @@
 template 
 _LIBCPP_ALWAYS_INLINE
 error_code(_Ep __e,
-   typename enable_if::value>::type* = 0
+   typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = make_error_code(__e);}
 
Index: include/string
===
--- include/string
+++ include/string
@@ -426,15 +426,15 @@
 typedef basic_string u16string;
 typedef basic_string u32string;
 
-intstoi  (const string& str, size_t* idx = 0, int base = 10);
-long   stol  (const string& str, size_t* idx = 0, int base = 10);
-unsigned long  stoul (const string& str, size_t* idx = 0, int base = 10);
-long long  stoll (const string& str, size_t* idx = 0, int base = 10);
-unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);
+intstoi  (const string& str, size_t* idx = nullptr, int base = 10);
+long   stol  (const string& str, size_t* idx = nullptr, int base = 10);
+unsigned long  stoul (const string& str, size_t* idx = nullptr, int base = 10);
+long long  stoll (const string& str, size_t* idx = nullptr, int base = 10);
+unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10);
 
-float   stof (const string& str, size_t* idx = 0);
-double  stod (const string& str, size_t* idx = 0);
-long double stold(const string& str, size_t* idx = 0);
+float   stof (const string& str, size_t* idx = nullptr);
+double  stod (const string& str, size_t* idx = nullptr);
+long double stold(const string& str, size_t* idx = nullptr);
 
 string to_string(int val);
 string to_string(unsigned val);
@@ -446,15 +446,15 @@
 string to_string(double val);
 string to_string(long double val);
 
-intstoi  (const wstring& str, size_t* idx = 0, int base = 10);
-long   stol  (const wstring& str, size_t* idx = 0, int base = 10);
-unsigned long  stoul (const wstring& str, size_t* idx = 0, int base = 10);
-long long  stoll (const wstring& str, size_t* idx = 0, int base = 10);
-unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);
+intstoi  (const wstring& str, size_t* idx = nullptr, int base = 10);
+long   stol  (const wstring& str, size_t* idx = nullptr, int base = 10);
+unsigned long  stoul (const wstring& str, size_t* idx = nullptr, int base = 10);
+long long  stoll (const wstring& str, size_t* idx = nullptr, int base = 10);
+unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10);
 
-float   stof (const wstring& str, size_t* idx = 0);
-double  stod (const wstring& str, size_t* idx = 0);
-long double stold(const wstring& str, size_t* idx = 0);
+float   stof (const wstring& str, size_t* idx = nullptr);
+double  stod (const wstring& str, size_t* idx = nullptr);
+long double stold(const wstring& str, size_t* idx = nullptr);
 
 wstring to_wstring(int val);
 wstring to_wstring(unsigned val);
@@ -3923,15 +3923,15 @@
 
 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
 
-_LIBCPP_FUNC_VIS intstoi  (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS long   stol  (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS unsigned long  stoul (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS long long  stoll (const string& __str, size_t* __idx = 0, int __base = 10);
-_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS intstoi  (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long   stol  (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long  stoul (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS long long  stoll (const string& __str, size_t* __idx = nullptr, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10);
 
-_LIBCPP_FUNC_VIS float   stof (const string& __str, size_t* __idx = 0);
-_LIBCPP_FUNC_VIS