[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 27 13:01:56 PDT 2018


ldionne added a comment.

It would be nice if all the TMP required to determine whether to call `__move_construct_forward(..., true_type)` or `__move_construct_forward(..., false_type)` was done in `__move_construct_forward` itself (or a helper). This way, callers wouldn't have to do it themselves. For example, vector currently needs

  typedef integral_constant<bool,
          __vector_should_construct_via_memcpy<_Tp, _Allocator>::value &&
          (is_same<_ForwardIterator, _Tp*>::value ||
           is_same<_ForwardIterator, const _Tp*>::value ||
           is_same<_ForwardIterator, pointer>::value)
      > __copy_via_memcpy;
  ...
  _VSTD::__copy_construct_forward(__a, __first, __last, this->__end_, __copy_via_memcpy());

It would be neat if we could just do

  VSTD::__copy_construct_forward(__a, __first, __last, this->__end_);

and have it dispatched correctly from there. That would make those functions potentially useful elsewhere. Does that make sense? Otherwise this LGTM.



================
Comment at: include/vector:296
+_LIBCPP_INLINE_VISIBILITY
+inline void
+__copy_construct_forward(_Alloc& __a, _Iter __begin1, _Iter __end1,
----------------
Do you really need `inline` here?


Repository:
  rCXX libc++

https://reviews.llvm.org/D49317





More information about the cfe-commits mailing list