建设设计项目备案在哪个网站网页设计与制作教程知识点

当前位置: 首页 > news >正文

建设设计项目备案在哪个网站,网页设计与制作教程知识点,内容营销是什么意思,网站发多少篇文章开始做外链https://www.boost.org/sgi/stl/character_traits.html char_traitschar char_traitswchar_ttraits翻译为特征、特性类#xff0c;一般是指某种类型的特性类应该提供的一组接口、类型定义。 web页面描述了一些接口要求。感觉没有什么特别的。直接看代码吧 c…https://www.boost.org/sgi/stl/character_traits.html char_traitschar char_traitswchar_ttraits翻译为特征、特性类一般是指某种类型的特性类应该提供的一组接口、类型定义。 web页面描述了一些接口要求。感觉没有什么特别的。直接看代码吧 char_traits.h文件中以下两个头文件不在sgi stl范围内属于c标准库的范围 在vs中创建一个空工程#include “…/stl/char_traits.h” 后就可以在vs中跳转过去看到的是windows的实现。 #include string.h #include wchar.h以上两个头文件定义了strcpy_s、_memccpy之类的基础C函数说明STL中的一些函数间接使用了C函数 __char_traits_base 定义了char类型的比较、赋值、拷贝、查找、求长度等基础函数 template class _CharT, class _IntT class __char_traits_base { public:typedef _CharT char_type;typedef _IntT int_type; #ifdef __STL_USE_NEW_IOSTREAMS //这个没用上暂时可以不管typedef streamoff off_type;typedef streampos pos_type;typedef mbstate_t state_type; #endif /* __STL_USE_NEW_IOSTREAMS /static void assign(char_type __c1, const char_type __c2) { __c1 __c2; }static bool eq(const _CharT __c1, const _CharT __c2) { return __c1 __c2; }static bool lt(const _CharT __c1, const _CharT __c2) { return __c1 __c2; }static int compare(const _CharT __s1, const _CharT* __s2, size_t __n) {for (size_t __i 0; __i __n; i)if (!eq(s1[__i], s2[i]))return s1[i] s2[i] ? -1 : 1;return 0;}static size_t length(const _CharT* __s) {const _CharT __nullchar _CharT();//默认构造函数必须置0(概念上可以不为0定义无歧义空值即可)size_t i;for (i 0; !eq(s[i], __nullchar); __i) {}return __i;}static const _CharT* find(const _CharT* __s, size_t __n, const _CharT __c) {//此处传值或许更好编译器优化后可能无差别for ( ; __n 0 ; s, –n)if (eq(__s, __c))return __s;return 0;}static _CharT move(_CharT* __s1, const _CharT* __s2, size_t n) {memmove(s1, __s2, n * sizeof(_CharT));//n 是__s1 __s2的sizereturn __s1;} static _CharT* copy(_CharT* __s1, const _CharT* __s2, size_t n) {memcpy(s1, __s2, __n * sizeof(_CharT));return __s1;} static _CharT* assign(_CharT* __s, size_t __n, _CharT __c) {for (size_t __i 0; __i __n; i)s[__i] __c;return __s;}static int_type not_eof(const int_type c) {return !eq_int_type(c, eof()) ? __c : 0;}static char_type to_char_type(const int_type c) {return static_castchar_type(c);}static int_type to_int_type(const char_type c) {return static_castint_type(c);}static bool eq_int_type(const int_type __c1, const int_type __c2) {return __c1 __c2;}static int_type eof() {return static_castint_type(-1);//-1为无效值大文件实际应该为long long -1} };POD表示Plain Old Data简单老数据衍生概念是指可简单拷贝内存复制对象的结构体含有指针的就不适合简单拷贝。 char_traits不适用与非POD类型。 template class _CharT class char_traits //特化版本与后面的char_traitschar特化不一样此处实际还没确定类型: public char_traits_base_CharT, _CharT {};STL_TEMPLATE_NULL class char_traitschar //char的特化版本重载了几个函数典型的是调用C函数的几个: public __char_traits_basechar, int{ public:static char_type to_char_type(const int_type c) {return static_castchar_type(static_castunsigned char(c));}static int_type to_int_type(const char_type c) {return static_castunsigned char(c);}static int compare(const char* __s1, const char* __s2, size_t n) { return memcmp(s1, __s2, __n); } static size_t length(const char* s) { return strlen(s); }static void assign(char __c1, const char __c2) { __c1 __c2; }static char* assign(char* __s, size_t __n, char c){ memset(s, __c, __n); return __s; } };wchar_t版本特化wint_t实际是unsigned short __STL_TEMPLATE_NULL class char_traitswchar_t: public __char_traits_basewchar_t, wint_t{};basic_string在string中定义web说明中没有很复杂基本就是template class _CharT, class _Traits, class _Alloc三个的组合 实际代码如下 #pragma set woff 1174 //这种用法比较少见据说是ms vs才支持的关闭告警语法 #pragma set woff 1375// A helper class to use a char_traits as a function object.将char_traits用作函数对象 template class _Traits struct _Not_within_traits //是否在内部找得到: public unary_functiontypename _Traits::char_type, bool{typedef const typename _Traits::char_type* _Pointer;const _Pointer _M_first;const _Pointer _M_last;_Not_within_traits(_Pointer __f, _Pointer l) : _M_first(f), _M_last(__l) {}bool operator()(const typename _Traits::char_type x) const {//找到了就在string内有x否则_Not_within_traitsreturn find_if(_M_first, _M_last, bind1st(_Eq_traits_Traits(), __x)) _M_last;}//bind1st存储了op和1st参数变成了一个一元仿函数对象再去操作序列中的元素。 }; template class _InputIter, class _Predicate inline _InputIter find_if(_InputIter __first, _InputIter __last,_Predicate pred,input_iterator_tag){while (first ! last !pred(first))//遇到相等就停不等于就循环下去first;return __first; } template class _Traits struct _Eq_traits: public binary_functiontypename _Traits::char_type,typename _Traits::char_type,bool{bool operator()(const typename _Traits::char_type __x,const typename _Traits::char_type y) const{ return _Traits::eq(x, __y); }//实际就是判断是否相等。封装是为了编译期检查 }; template class _Arg1, class _Arg2, class _Result struct binary_function { //二元函数typedef _Arg1 first_argument_type;typedef _Arg2 second_argument_type;typedef _Result result_type; };
template class _Operation, class _Tp//_Operation _Eq_traits_Traits() inline binder1st_Operation //返回值是一个函数对象编译后可能是函数指针或者内联 bind1st(const _Operation __fn, const _Tp x) {typedef typename _Operation::first_argument_type _Arg1_type;return binder1st_Operation(fn, _Arg1_type(x));//说明x是__fn的第一个参数 } template class _Operation class binder1st : public unary_functiontypename _Operation::second_argument_type,typename _Operation::result_type { protected:_Operation op;//操作的存储使得当前类替代了被绑定的操作操作的递归替换typename _Operation::first_argument_type value;//降元的本质就是将部分存到仿函数内部。 public:binder1st(const _Operation __x,const typename _Operation::first_argument_type y): op(x), value(__y) {}//bind1st(_Eq_traits_Traits(), __x)把第一个参数绑定实际是存储起来typename _Operation::result_typeoperator()(const typename _Operation::second_argument_type __x) const {//与第二个参数进行操作eg判断是否相等return op(value, __x); } };前面这段代码比较难看懂的是以下这句 return find_if(_M_first, _M_last, bind1st(_Eq_traits_Traits(), __x)) _M_last; //bind1st存储了op和1st参数变成了一个一元仿函数对象再去操作序列中的元素。 //find_if返回值是序列的指针指针指向的对象满足bind1st绑定后的一元仿函数返回值true find_if这种函数只接受一元仿函数bind1st实现了操作降元二元操作降到一元操作类似降元都可以模仿着写本质就是将第一个元存到仿函数内部。 // General base class. template class _Tp, class _Alloc, bool _S_instanceless//instanceless _Alloc是否无实例 class _String_alloc_base { //提供内存管理 public:typedef typename _Alloc_traits_Tp, _Alloc::allocator_type allocator_type;//new delete仿函数类型定义allocator_type get_allocator() const { return _M_data_allocator; }//获得内部的new delete仿函数对象_String_alloc_base(const allocator_type a): _M_data_allocator(a), _M_start(0), _M_finish(0), _M_end_of_storage(0) {} protected:_Tp
_M_allocate(size_t n){ return _M_data_allocator.allocate(n); }//newvoid _M_deallocate(_Tp* __p, size_t n) {if (p)_M_data_allocator.deallocate(__p, __n); //delete} protected:allocator_type _M_data_allocator; //仿函数对象默认false无实例的false就是此处有_Alloc示例此处占内存_Tp* _M_start;//起始指针_Tp* _M_finish;//已用范围的尾部指针_Tp* _M_end_of_storage; //标识最大容量指针 };_String_alloc_base 的特化版本 // Specialization for instanceless allocators. template class _Tp, class _Alloc class _String_alloc_base_Tp,_Alloc,true { public:typedef typename _Alloc_traits_Tp, _Alloc::allocator_type allocator_type;//此处无实例化就是定义allocator_typeallocator_type get_allocator() const { return allocator_type(); }_String_alloc_base(const allocator_type) : _M_start(0), _M_finish(0), _M_end_of_storage(0) {} protected:typedef typename _Alloc_traits_Tp, _Alloc::_Alloc_type _Alloc_type;_Tp* _M_allocate(size_t n) { return _Alloc_type::allocate(n); }void _M_deallocate(_Tp* __p, size_t n) { _Alloc_type::deallocate(p, __n); } protected:_Tp* _M_start;_Tp* _M_finish;_Tp* _M_end_of_storage; };template class _Tp, class _Alloc class _String_base : public _String_alloc_base_Tp, _Alloc,_Alloc_traits_Tp, _Alloc::_S_instanceless{ protected:typedef _String_alloc_base_Tp, _Alloc,_Alloc_traits_Tp, _Alloc::_S_instanceless _Base;typedef typename _Base::allocator_type allocator_type;void _M_allocate_block(size_t n) { if (n max_size()) {_M_start _M_allocate(__n);_M_finish _M_start;_M_end_of_storage _M_start __n;}else_M_throw_length_error();}void _M_deallocate_block() { _M_deallocate(_M_start, _M_end_of_storage - _M_start); } size_t max_size() const { return (size_t(-1) / sizeof(_Tp)) - 1; }_String_base(const allocator_type a) : _Base(a) { } _String_base(const allocator_type __a, size_t n) : _Base(a){ _M_allocate_block(n); }~_String_base() { _M_deallocate_block(); }void _M_throw_length_error() const;//两种异常之一。类外定义防止内联void _M_throw_out_of_range() const;//两种异常之一 }; // Helper functions for exception handling. template class _Tp, class _Alloc void _String_base_Tp,_Alloc::_M_throw_length_error() const {STL_THROW(length_error(basic_string));//两种异常之一 } template class _Tp, class _Alloc void _String_base_Tp, _Alloc::_M_throw_out_of_range() const {__STL_THROW(out_of_range(basic_string));//两种异常之一 }未完待续