文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 侯捷stl源码剖析注释之20 sgi-stl-algobase
侵权投诉

侯捷stl源码剖析注释之20 sgi-stl-algobase

sgi-stl-algobase

4 <stl_algobase.h> 完整列表 return __copy_d(first, last, result, distance_type(first));

}

template <class InputIterator, class OutputIterator>

struct __copy_dispatch

{

OutputIterator operator()(InputIterator first, InputIterator last,

OutputIterator result) {

return __copy(first, last, result, iterator_category(first));

}

};

#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION

template <class T>

inline T* __copy_t(const T* first, const T* last, T* result, __true_type) { memmove(result, first, sizeof(T) * (last - first));

return result + (last - first);

}

template <class T>

inline T* __copy_t(const T* first, const T* last, T* result, __false_type) { return __copy_d(first, last, result, (ptrdiff_t*) 0);

}

template <class T>

struct __copy_dispatch<T*, T*>

{

T* operator()(T* first, T* last, T* result) {

typedef typename __type_traits<T>::has_trivial_assignment_operator t; return __copy_t(first, last, result, t());

}

};

template <class T>

struct __copy_dispatch<const T*, T*>

{

T* operator()(const T* first, const T* last, T* result) {

typedef typename __type_traits<T>::has_trivial_assignment_operator t; return __copy_t(first, last, result, t());

}

};

#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

// copy 函式運用了 function overloading, type traits, partial

// specialization, 無所不用其極地改善效率。

template <class InputIterator, class OutputIterator>

inline OutputIterator copy(InputIterator first, InputIterator last,

The Annotated STL Sources

上一页第4页

你可能喜欢

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email