[libcxx-commits] [PATCH] D43159: Modernize: Use nullptr more.

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 3 08:41:45 PDT 2019


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 <class _Tp>
    _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT
        {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
```

to:
```
    template <class _Tp>
    _LIBCPP_INLINE_VISIBILITY void __incr() _NOEXCEPT
        {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
```

and remove the `nullptr`s from the calls in `<algorithm>`
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





More information about the libcxx-commits mailing list