dimanche 26 juillet 2015

implementation of stl copy function?

Here is some implementation details of the std::copy function(from vs2015):

template<class _InIt,
    class _OutIt> inline
    _OutIt _Copy_impl(_InIt _First, _InIt _Last,
        _OutIt _Dest, _Scalar_ptr_iterator_tag)
    {   // copy [_First, _Last) to [_Dest, ...), pointers to scalars
    ptrdiff_t _Count = _Last - _First;
    _CSTD memmove(&*_Dest, &*_First,
        _Count * sizeof (*_First));
    return (_Dest + _Count);
    }

It seems that we can just use the memmove in case of scalar type.But why can't we use memmove if it is POD type (C++11)?As far as I know, it's both trivial and standard layout.

Aucun commentaire:

Enregistrer un commentaire