Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FUNCTION TEMPLATE uninitialized_copy
- template<class _InIt,
- class _FwdIt> inline
- _FwdIt _Uninitialized_copy_unchecked(_InIt _First, _InIt _Last,
- _FwdIt _Dest, _General_ptr_iterator_tag)
- { // copy [_First, _Last) to raw [_Dest, ...), no special optimization
- const _FwdIt _Next = _Dest;
- _TRY_BEGIN
- for (; _First != _Last; ++_Dest, (void)++_First)
- {
- _Construct_in_place(*_Dest, *_First);
- }
- _CATCH_ALL
- _Destroy_range(_Next, _Dest);
- _RERAISE;
- _CATCH_END
- return (_Dest);
- }
- template<class _InIt,
- class _FwdIt> inline
- _FwdIt _Uninitialized_copy_unchecked(_InIt _First, _InIt _Last,
- _FwdIt _Dest, _Really_trivial_ptr_iterator_tag)
- { // copy [_First, _Last) to raw [_Dest, ...), memmove optimization
- return (_Copy_memmove(_First, _Last, _Dest));
- }
- template<class _InIt,
- class _FwdIt> inline
- _FwdIt uninitialized_copy(_InIt _First, _InIt _Last,
- _FwdIt _Dest)
- { // copy [_First, _Last) to raw [_Dest, ...)
- _DEPRECATE_UNCHECKED(uninitialized_copy, _Dest);
- _DEBUG_RANGE(_First, _Last);
- const auto _UFirst = _Unchecked(_First);
- const auto _ULast = _Unchecked(_Last);
- const auto _UDest = _Unchecked_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast));
- return (_Rechecked(_Dest,
- _Uninitialized_copy_unchecked(_UFirst, _ULast, _UDest, _Ptr_copy_cat(_UFirst, _UDest))));
- }
- // TEMPLATE FUNCTIONS _Ptr_copy_cat AND _Ptr_move_cat
- template<class _Source,
- class _Dest>
- struct _Ptr_cat_helper
- { // determines _Ptr_cat's result in the most general case
- using _USource = typename _Unwrap_enum<_Source>::type;
- using _UDest = typename _Unwrap_enum<_Dest>::type;
- using type = conditional_t<conjunction<
- _Is_same_size<_USource, _UDest>,
- is_integral<_USource>,
- is_integral<_UDest>,
- _Both_or_neither_bool<_USource, _UDest>
- >::value,
- _Really_trivial_ptr_iterator_tag,
- _General_ptr_iterator_tag>;
- };
- template<class _Elem>
- struct _Ptr_cat_helper<_Elem, _Elem>
- { // determines _Ptr_cat's result when the types are the same
- using type = conditional_t<
- is_trivially_copyable<_Elem>::value,
- conditional_t<is_trivial<_Elem>::value,
- _Really_trivial_ptr_iterator_tag,
- _Trivially_copyable_ptr_iterator_tag>,
- _General_ptr_iterator_tag>;
- };
- template<class _Anything>
- struct _Ptr_cat_helper<_Anything *, const _Anything *>
- { // determines _Ptr_cat's result when all we do is add const to a pointer
- using type = _Really_trivial_ptr_iterator_tag;
- };
- template<class _Anything>
- struct _Ptr_cat_helper<_Anything *, volatile _Anything *>
- { // determines _Ptr_cat's result when all we do is add volatile to a pointer
- using type = _Really_trivial_ptr_iterator_tag;
- };
- template<class _Anything>
- struct _Ptr_cat_helper<_Anything *, const volatile _Anything *>
- { // determines _Ptr_cat's result when all we do is add cv to a pointer
- using type = _Really_trivial_ptr_iterator_tag;
- };
- template<class _Source,
- class _Dest> inline
- _General_ptr_iterator_tag _Ptr_copy_cat(const _Source&, const _Dest&)
- { // return pointer copy optimization category for arbitrary iterators
- return {};
- }
- template<class _Source,
- class _Dest> inline
- conditional_t<is_trivially_assignable<_Dest&, _Source&>::value,
- typename _Ptr_cat_helper<remove_cv_t<_Source>, remove_cv_t<_Dest>>::type,
- _General_ptr_iterator_tag>
- _Ptr_copy_cat(_Source * const&, _Dest * const&)
- { // return pointer copy optimization category for pointers
- return {};
- }
- template<class _Source,
- class _Dest> inline
- _General_ptr_iterator_tag _Ptr_move_cat(const _Source&, const _Dest&)
- { // return pointer move optimization category for arbitrary iterators
- return {};
- }
- template<class _Source,
- class _Dest> inline
- conditional_t<is_trivially_assignable<_Dest&, _Source>::value,
- typename _Ptr_cat_helper<remove_cv_t<_Source>, remove_cv_t<_Dest>>::type,
- _General_ptr_iterator_tag>
- _Ptr_move_cat(_Source * const&, _Dest * const&)
- { // return pointer move optimization category for pointers
- return {};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement