侯老师--STL源码剖析--书中的疑问三

《STL源码剖析》学习之traits编程 在设计模式中有一种模式叫迭代器模式,简单来说就是提供一种方法,在不需要暴露某个容器的内部表现形式情况下,使之能依次访问该容器中的各个元素,这种设计思维在STL中得到了广泛的应用,是STL的关键所在,通过迭代器,容器和算法可以有机的粘合在一起。在这里提到了一个叫迭代器的东西.... 阅读详情

 

侯老师--STL源码剖析--书中的疑问三

前言

我在看侯捷的STL源码剖析一书中”第二章2.2具备次配置力(sub-allocation)的SGI空间配置器(第47页)看到了如下的代码,我认为是有错误的。

SGI空间配置器原文

       ……

SGI的空间配置器与众不同,也和标准规格不同,其名称为alloc而非allocator,而且不接收任何引数。换句话说如果你要在程式中明白采用SGI空间配置器,不能采用标准写法。

vector<int, std::allocate<int> > iv;               //in VC or CB

必须这么写:

vector<int, std::alloc > iv;                      //in GCC

……

以上是原文的摘录,我个人认为语句:

vector<int, std::allocate<int> > iv;               //in VC or CB

中的std::allocate并不存在,而应该为std::allocator。所以应改为

vector<int, std::allocator<int> > iv;                   //in VC or CB

 

这可能是侯老师的笔误,但是这不代表我说的一定对,侯老师一定写错了。我只是把我个人的观点写出来,很可能是我错了(学习不精),请大家批评指教,共同进步吗!如果能够得到侯老师的指点是再好不过了^_^。

总之,请大家多多批评指教,来信至ccplusplus@21cn.com。

 

    致谢!

                                                                袁小凯

                                                             2001-11-14 

【STL源码剖析】总结笔记(1):开篇 00 写在前面 STL作为C++标准库中的重要组成部分,在学习C++过程中非常重要。这个可以复用的组件库更像是一个包罗万象的“框架”。 侯捷老师对于STL的了解之深也使我受益匪浅。而《STL源码剖析》这本书也是集精华于一体,深度探索了对于STL的各个部分。配合老师的视频食用极佳。 从这篇开始,我想根据视频和书籍的主要内容做一些整理以及一些理解部分的记录。因为视频部分和书籍部分不完全重合,又是各有精华,所以十分值得去整合在一起理解学习。 学习STL需要读者有一定的C++基础能力,且有一些使用STL的经验,这 阅读详情

相关推荐

STL源码剖析——RB-Tree(红黑树)

前言 有关红黑树的zh

关注校招求职,微信号:job_campus 2869

侯老师--STL源码剖析--书中的疑问三 (转)

侯老师--STL源码剖析--书中的疑问三 (转)[@more@] 侯老师--STL源码剖析--书中的疑问三XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Of...

csd3176的博客 150

STL-源码剖析 简单总结

STL-源码剖析STL 六大组件 功能与运用1. 容器2. 算法3. 迭代器4. 仿函数5. 配接器(adapters)6. 配置器(allocators)空间配置器(allocator)迭代器(iterators)概念与traits编程技法序列式容器vectorlistdeque![在这里插入图片描述](https://img-blog.csdnimg.cn/20190523165012839....

shaoye_csdn1的博客 1131

侯老师--STL源码剖析--书中的疑问一

侯老师--STL源码剖析--书中的疑问一前言我在看侯捷的STL源码剖析一书中”第一章Class的语法和语意(第30页)”看到了如下的伪代码,我认为是有错误的,因为代码中在没有初始化迭代子的情况下使用。代码如下:状态8:__STL_MEMBER_TEMPLATES#include using namespace std;class alloc{}; templ

winmain的专栏 1148

手把手教你用单结晶体管搭建简易振荡电路(含电路图和波形分析)

本文详细介绍了如何使用单结晶体管(UJT)搭建简易振荡电路,包括电路设计、波形分析和实战技巧。通过具体的电路图和参数计算,帮助电子爱好者和工程师快速掌握UJT振荡器的设计与调试方法,适用于脉冲信号生成和时钟源制作等应用场景。

weixin_29207533的博客 526

DAP-Link DIY复刻指南

DAP-Link是ARM开源的一个项目,主要用于代码下载以及调试,支持SWD和JTAG调试接口,对于开发嵌入式的同学相信都或多或少有所耳闻。除了DAP-Link之外还有很多同类型的调试器,如ST-LinkJ-Link,但是这些都是不开源的,无法复刻或进行二次开发。但DAP-Link不同,完全开源,不用担心侵权问题,且随着开源社区大家的共同努力,DAP-Link经过了不断的迭代,先如今已取代ARM之前推出的CMSIS-DAP开源项目。

爱出名的狗腿子 1万+

侯老师--STL源码剖析--书中的疑问二

 侯老师--STL源码剖析--书中的错误二前言我在看侯捷的STL源码剖析一书中”第二章设计一个阳春的空间配置器JJ::allocator(第45页)看到了如下的伪代码,我认为是有错误的,代码如下:命名空间JJ中代码……templateinline void _construct(T1* p, const T2& value){    new(p) T1(valu

winmain的专栏 1441

PBR:双向反射分布函数(BRDF)介绍与Cook-Torrance模型的实现

PBR:双向反射分布函数(BRDF)介绍与Cook-Torrance模型的实现 BRDF简介 再介绍BRDF之前我们要引入渲染方程这个东西: 其中L表示辐射率,其公式为: 它表示了一个拥有辐射强度Φ的光源在单位面积A,单位立体角ω上的辐射出的总能量。 辐射率是辐射度量学上表示一个区域平面上光线总量的物理量,它受到入射光线与平面法线间的夹角θ的余弦值cosθ的影响:当直接...

小龙虾的博客 1万+

候捷老师STL源码剖析视频课程笔记

本文是我在学习候捷《STL标准库和泛型编程》课程时所做的笔记。在此分享给大家

weixin_46065476的博客 1138

如何导入su_利用GIS快速生成SU场地模型

01|前言:进入2021年了,希望大家也是一个新的开始。告诫自己多写文章多更新,多读点书多旅行。然而元旦由于出去玩了4天,积累了一些事情要处理,一直没有时间好好写点东西。今天给大家带来的分享主题叫“利用GIS快速生成SU场地模型”。相关的视频方法其实B站上也有,但我相信视频很多人都不会看,我自己也是。直接给大家上操作流程。主要的操作步骤是【获取场地的矢量shp文件】—【导入ArcScen...

weixin_33806859的博客 9829

深入解析fio Benchmark测试:从源码到实践

本文深入解析fio Benchmark测试工具,从入门指南到源码架构分析,详细介绍了其核心模块、关键数据结构和I/O处理机制。通过实战案例展示如何优化存储性能测试,包括内存对齐、多线程调优等技巧,帮助开发者充分利用fio进行精准的存储性能评估。

weixin_42563415的博客 215

《STL源码剖析》学习笔记(一):编译器与STL版本

最近在学习侯捷老师的《STL源码剖析》,这本书很老了,里面使用的例程在我的IDE上无法运行(我的IDE是

JH_Shawlin的博客 1255

硬件测试实战笔记:SI/PI 到底测什么,怎么测?一文讲清

点选错了,数据越精确越误导。

qq_52293640的博客 320

侯老师--STL源码剖析--书中的疑问一 (转)

侯老师--STL源码剖析--书中的疑问一 (转)[@more@]侯老师--STL源码剖析--书中的疑问一XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Offic...

csd3176的博客 126

kylinos-SP3的软件包降级到V10-SP1中的版本

如果想再次回退到原来版本,将repo改为原来的SP3版本,然后执行yum history 查看ID号,执行yum history rollback ID就可以恢复了。此时我们发现已安装的版本是1.32-2.ky10,而sp1网络源里的版本是1.30-11.ky10,我们将降级安装网络源中的低版本软件包。近期有个客户想要把kylinos-V10-sp3的软件包降级到kylinos-V10-SP1的版本。3、以tar包为例,查看已安装版本及网络源中其他版本。1、查看系统版本,确认是V10-SP3。

太极淘的博客 1110

【图像超分】论文复现:CVPR 2024 | 轻量化超分 | 窗口注意力改进 | CAMixerSR的Pytorch源码复现,跑通源码,获得指标和超分结果,计算复杂度,架构梳理拆解,逐行注释!

本文介绍了超分辨率重建方法CAMixerSR的代码实现与运行指南。文章亮点包括:完整跑通源码获取PSNR/SSIM指标和可视化结果;详细解析模型架构与关键代码注释,帮助快速复现基线模型。实验部分提供了测试配置文件和训练设置说明,支持2K/4K/8K大图像超分和x2/x4轻量化超分。环境依赖PyTorch和BasicSR框架,数据集包含DIV2K等常用基准。测试结果与论文指标一致,可视化输出保存至指定目录。训练配置可自定义数据集路径、GPU数量等参数。该实现突出了CAMixerSR在降低W-MSA复杂度方面的

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 452

侯老师--STL源码剖析--书中的疑问二 (转)

侯老师--STL源码剖析--书中的疑问二 (转)[@more@]XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office:office" /> 侯...

csd3176的博客 253

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

侯捷老师——STL源码剖析

generic programming GP 泛型编程 object oriented OO 面向对象 C++ Standard Library C++标准库 Standard Template Library STL 标准模板库 P1 认识headers、版本、重要资源 C++标准库中有百分之八十左右都是由 STL组成的 常用网站: cplusplus.com cppreference.com gcc.gnu.org 建议阅读书籍...

linping_的博客 1509

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

【STL源码剖析第一章】

STL(Standard Template Library,标准模板库)是 C++ 中最具代表性的库之一。它通过,让我们能够高效地管理数据、复用算法,并以统一的方式连接二者。侯捷老师在《STL源码剖析》中,将 STL 的结构总结为六大组件:容器、算法、迭代器、仿函数、适配器、空间配置器。这一章的核心就是理解它们的作用与关系。

weixin_52227132的博客 1317

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

STL源码剖析总结

侯老师说泛型技术学习分三层境界,最高境界自然就是自行扩展STL了,要自行扩展不单要清楚STL的实现及原理还要对STL有深刻理解,以达到能够编写无缝融入STL的自行扩展的组件,嘛,就是写库吧 下面就贴上一个自己写的简单的数组容器,当然迭代器为原始指针所以就不需要专门编写迭代器,STL也提供了原始指针的特化版本萃取机,所以并不需要为迭代器编写额外代码(要不然就麻烦了),为了更好理解STL空间配置器也

无题 843

【C++】透过STL源码深度剖析及模拟实现vector

STL之vector类的深度剖析及模拟实现

做技术人 · 产优质博客 · 找好工作 1696

读完两遍《STL源码剖析》后,我发现了一些辛秘

前排提醒本文是阿秀以前给某位大佬投稿的文章改编而来,当时自己文笔还较弱,现重新改写润色一下发表出来,希望与大家共同进步!阅读本文需要具备一些C++基础,不是面向小白的文章,可以说是又一篇干...

博客 1333

STL(C++标准库,体系结构及其内核分析)(STL源码剖析)(更新完毕)

STL(C++标准库,体系结构及其内核分析)(STL源码剖析)(更新完毕)

世界仙境与冷酷尽头's Blog 7851

stl源码剖析_STL源码剖析——allocator分配器(上)

写在前面最近在阅读候捷老师的《STL源码剖析》,阅读到空间配置器(allocator)这一章,觉得非常受用。这篇文章就当作自己的学习笔记,下面我会从头到尾梳理一遍 allocator 的重点和难点,希望对这方面不了解的读者看完后有所收获。什么是 allocator?allocator 有什么用?我们需要对 C++ 的 allocator 的堆内存接口调用顺序有个清晰的认识,如下图所示。alloca...

weixin_39918043的博客 302

STL源码剖析(一):STL概论

本系列是结合侯捷老师的 STL源码剖析这本书看的,有理解不到位的地方,敬请提出。 版本 首先,需了解以下三个C++编译器: GNU:Unix下的编译器 VC++:windows平台下的编译器,微软公司开发,因为windows操作系统都是微软的,所以它是主要的windows平台下编译工具 C++ Builder:英巴卡迪诺公司开发的windows平台编译器,Delphi的姊妹,比较小众。 STL的原始版本是HP(惠普)版本,以下三个STL版本都继承了HP版本: GCC采用SGI STL版本。(GC

youaremyalllove的博客 526

【免费下载】 STL源码剖析资源下载

STL源码剖析资源下载 【下载地址】STL源码剖析资源下载 STL源码剖析资源下载本仓库提供了一个名为“STL源码剖析pdf及源码.zip”的资源文件下载 项目地址: https://gitcode.com/open-source...

gitblog_09723的博客 550
上一篇: STL程序设计实践一:谨慎使用下标运算符
下一篇: 侯老师--STL源码剖析--书中的疑问一
winmain
博客等级 码龄26年 5粉丝 18原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址