Guest User

MSVC uninitialized_copy

a guest
Nov 23rd, 2017
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         // FUNCTION TEMPLATE uninitialized_copy
  2. template<class _InIt,
  3.     class _FwdIt> inline
  4.     _FwdIt _Uninitialized_copy_unchecked(_InIt _First, _InIt _Last,
  5.         _FwdIt _Dest, _General_ptr_iterator_tag)
  6.     {   // copy [_First, _Last) to raw [_Dest, ...), no special optimization
  7.     const _FwdIt _Next = _Dest;
  8.  
  9.     _TRY_BEGIN
  10.     for (; _First != _Last; ++_Dest, (void)++_First)
  11.         {
  12.         _Construct_in_place(*_Dest, *_First);
  13.         }
  14.  
  15.     _CATCH_ALL
  16.     _Destroy_range(_Next, _Dest);
  17.     _RERAISE;
  18.     _CATCH_END
  19.  
  20.     return (_Dest);
  21.     }
  22.  
  23. template<class _InIt,
  24.     class _FwdIt> inline
  25.     _FwdIt _Uninitialized_copy_unchecked(_InIt _First, _InIt _Last,
  26.         _FwdIt _Dest, _Really_trivial_ptr_iterator_tag)
  27.     {   // copy [_First, _Last) to raw [_Dest, ...), memmove optimization
  28.     return (_Copy_memmove(_First, _Last, _Dest));
  29.     }
  30.  
  31. template<class _InIt,
  32.     class _FwdIt> inline
  33.     _FwdIt uninitialized_copy(_InIt _First, _InIt _Last,
  34.         _FwdIt _Dest)
  35.     {   // copy [_First, _Last) to raw [_Dest, ...)
  36.     _DEPRECATE_UNCHECKED(uninitialized_copy, _Dest);
  37.     _DEBUG_RANGE(_First, _Last);
  38.     const auto _UFirst = _Unchecked(_First);
  39.     const auto _ULast = _Unchecked(_Last);
  40.     const auto _UDest = _Unchecked_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast));
  41.     return (_Rechecked(_Dest,
  42.         _Uninitialized_copy_unchecked(_UFirst, _ULast, _UDest, _Ptr_copy_cat(_UFirst, _UDest))));
  43.     }
  44.  
  45. // TEMPLATE FUNCTIONS _Ptr_copy_cat AND _Ptr_move_cat
  46. template<class _Source,
  47.     class _Dest>
  48.     struct _Ptr_cat_helper
  49.     {   // determines _Ptr_cat's result in the most general case
  50.     using _USource = typename _Unwrap_enum<_Source>::type;
  51.     using _UDest = typename _Unwrap_enum<_Dest>::type;
  52.     using type = conditional_t<conjunction<
  53.             _Is_same_size<_USource, _UDest>,
  54.             is_integral<_USource>,
  55.             is_integral<_UDest>,
  56.             _Both_or_neither_bool<_USource, _UDest>
  57.         >::value,
  58.         _Really_trivial_ptr_iterator_tag,
  59.         _General_ptr_iterator_tag>;
  60.     };
  61.  
  62. template<class _Elem>
  63.     struct _Ptr_cat_helper<_Elem, _Elem>
  64.     {   // determines _Ptr_cat's result when the types are the same
  65.     using type = conditional_t<
  66.         is_trivially_copyable<_Elem>::value,
  67.         conditional_t<is_trivial<_Elem>::value,
  68.             _Really_trivial_ptr_iterator_tag,
  69.             _Trivially_copyable_ptr_iterator_tag>,
  70.         _General_ptr_iterator_tag>;
  71.     };
  72.  
  73. template<class _Anything>
  74.     struct _Ptr_cat_helper<_Anything *, const _Anything *>
  75.     {   // determines _Ptr_cat's result when all we do is add const to a pointer
  76.     using type = _Really_trivial_ptr_iterator_tag;
  77.     };
  78.  
  79. template<class _Anything>
  80.     struct _Ptr_cat_helper<_Anything *, volatile _Anything *>
  81.     {   // determines _Ptr_cat's result when all we do is add volatile to a pointer
  82.     using type = _Really_trivial_ptr_iterator_tag;
  83.     };
  84.  
  85. template<class _Anything>
  86.     struct _Ptr_cat_helper<_Anything *, const volatile _Anything *>
  87.     {   // determines _Ptr_cat's result when all we do is add cv to a pointer
  88.     using type = _Really_trivial_ptr_iterator_tag;
  89.     };
  90.  
  91. template<class _Source,
  92.     class _Dest> inline
  93.     _General_ptr_iterator_tag _Ptr_copy_cat(const _Source&, const _Dest&)
  94.     {   // return pointer copy optimization category for arbitrary iterators
  95.     return {};
  96.     }
  97.  
  98. template<class _Source,
  99.     class _Dest> inline
  100.     conditional_t<is_trivially_assignable<_Dest&, _Source&>::value,
  101.         typename _Ptr_cat_helper<remove_cv_t<_Source>, remove_cv_t<_Dest>>::type,
  102.         _General_ptr_iterator_tag>
  103.         _Ptr_copy_cat(_Source * const&, _Dest * const&)
  104.     {   // return pointer copy optimization category for pointers
  105.     return {};
  106.     }
  107.  
  108. template<class _Source,
  109.     class _Dest> inline
  110.     _General_ptr_iterator_tag _Ptr_move_cat(const _Source&, const _Dest&)
  111.     {   // return pointer move optimization category for arbitrary iterators
  112.     return {};
  113.     }
  114.  
  115. template<class _Source,
  116.     class _Dest> inline
  117.     conditional_t<is_trivially_assignable<_Dest&, _Source>::value,
  118.         typename _Ptr_cat_helper<remove_cv_t<_Source>, remove_cv_t<_Dest>>::type,
  119.         _General_ptr_iterator_tag>
  120.         _Ptr_move_cat(_Source * const&, _Dest * const&)
  121.     {   // return pointer move optimization category for pointers
  122.     return {};
  123.     }
RAW Paste Data