boost_foreach

 

  1 #include <string>
  2 #include <iostream>
  3 #include <boost/foreach.hpp>
  4 
  5 #define foreach BOOST_FOREACH
  6 
  7 
  8 int main()
  9 {
 10     std::string hello("Hello,World!");
 11 
 12     foreach(char ch,hello)
 13     {
 14         std::cout << ch;
 15     }
 16 
 17     return 0;
 18 }

 支持类型:STL containers,arrays,Null-terminated strings,std::pair of iterators

【BOOST C++ 16 语言扩展】(2) Boost.Foreach Boost.Foreach 提供了一个宏来模拟 C++11 中基于范围的 for 循环。您可以使用在 boost/foreach.hpp 中定义的宏 BOOST_FOREACH 来迭代序列而不使用迭代器。如果你的开发环境支持C++11,可以忽略Boost.Foreach。 阅读详情

相关推荐

使用运放构建电压跟随器

运放,是运算放大器的简称 运算放大器是用模拟电子器件(如晶体管,场效应管,二极管等)构成的模拟集成电路,其特点是有很高的放大倍数和抗干扰能力,因此可以被设计成各种用途的派生电路,如电压比较器、窗口电路、波形发生电路等等,其中也有电压跟随器。 电压跟随器是一种具有100%电压负反馈的放大器电路,其特点是输出电压的幅度和极性都与输入电压相同,所以叫跟随器。典型线路如图所示: 运放跟随器有输入阻抗高,而输出阻抗低的特性,一般来说,输入阻抗可以达到几兆欧姆,而输出阻抗低,通常只有几欧姆,甚至更低。 在电

Code for Coffee 5万+

用BOOST_FOREACH简化遍历操作

BOOST_FOREACH可以方便的遍历STL容器. 只需要头文件: #include 然后遍历容器vector/list/set/deque/stack/queue都是类似的: vectorint32_t> _v; BOOST_FOREACH(int32_t value,_v) { //这里就可以访问value } 同时元素还支持引用,const,比如

独孤——依人 2360

【scratch音乐课】天空之城:音符与节拍、消息与链表

scratch是一个非常小巧的青少年编程工具,自带程序编写语句,积木式语句非常直观、易用,可创作数学、科学、音乐、绘画等方面作品。本文用scratch“演奏”一首大家非常熟悉的《天空之城》,并向大家介绍一些基本乐理知识,以及scratch中消息、链表的使用。

★·°立芯;︶︵︶ 1万+

BOOST_FOREACH

成天写迭代器,写的手指都疼,BOOST_FOREACH可以方便的遍历STL容器. 只需要头文件: #include 然后遍历容器vector/list/set/deque/stack/queue都是类似的: vectorint32_t> _v; BOOST_FOREACH(int32_t value,_v) { //这里就可以访问value } 同时元素

zhanghuan_wangkai的博客 713

【TC3xx芯片】TC3xx芯片电源管理系统PMS详解

本文主要介绍了TC3xx芯片的电源管理系统(PMS),重点探讨了供电模式选择、电源监控机制及电源管理模式。文章首先分析了4种供电模式及其硬件配置方式,详细说明了3.3V单电源供电模式的特点;其次阐述了Primary和Secondary两种电源监控机制,包括阈值配置和异常中断处理;最后重点讲解了CPU和系统的电源管理模式,特别对Standby模式及其进入/退出条件进行了详细说明。文章以软件开发视角解析了TC3xx芯片的电源管理功能,为ECU低功耗设计提供了技术参考。

redparrot2008的博客 1532

基于FPGA的cy7c68013a双向通信实验

基于FPGA的cy7c68013a双向通信实验     本实验是基于FPGA的cy7c68013a的USB双向通信实验,以前折腾过一段时间cy7c68013a,没有入门时感觉好难,入门了就会感觉很简单。本教程主要内容:     1.cy7c68013a的固件编写,以及生成iic固件和下载固件。     2.cy7c68013a的slave模式,以及他的读写时序     3.cy7c6801...

乘风的博客 3万+

BOOST_FOREACH缺陷

以下来自手册: 缺陷 本节描述 BOOST_FOREACH 中的一些常见的缺陷。 带逗号的类型 由于 BOOST_FOREACH 是一个宏,它必须刚好有两个参数,并以一个逗号分隔它们。这并不总是很方便,尤其当循环变量的类型是一个模板的时候。考虑一下对 std::map 进行迭代: std::mapint,int> m; // 错误!BOOST_FOREACH 宏参

永无止境 1375

数据仓库实践:从ITR流程讲指标体系建设

从 ITR 流程或者其他客服反馈流程的考核过程可见,实际工作中不可能只通过单个指标评价一个业务过程,需要从多个维度梳理业务,并把多个高度相关的指标组织起来,以避免只考虑其中某个指标从而摧毁整个业务过程的结果,指标体系=指标+体系。

the_singing_towers的博客 2269

boost之Boost.Foreach遍历

类似perl和c#的foreach,BOOST_FOREACH给我们带来了一种简单而有效的遍历数组的方式。 让我们首先来看个简单的例子: [cpp] view plain copy #include   #include   #include     int main()  {      std::string hello( "Hello, world!" 

akjw008的专栏 1024

从入门到精通:用友BIP旗舰版全模块实施与运维实战指南

本文详细介绍了用友BIP旗舰版的全模块实施与运维实战指南,涵盖财务云、供应链云、生产制造等核心模块的配置与优化技巧。通过渐进式学习法和实战案例,帮助用户从入门到精通,提升系统实施效率和运维能力,特别适合企业IT人员和实施顾问参考。

weixin_29207533的博客 902

团结引擎+OpenHarmony 记录 (持续更新中)

获取不到的原因是因为二者不在同一个线程中,所以数据没有同步。而 globalThis.context 数据进行了同步。(TuanjieMainWorkerHandler.ts中可以看到)在进行绘制 UI 的时候 ,如果组件有 Native API 就可能不会显示出来,例如 web 控件就不能展示出来,刚加上权限的时候 会报错 因为缺少 reason ,添加上就不会报错了。只有纯 UI 控件是可以展示出来的,注释掉 web控件后就可以。

m_cainiaokuaifei的博客 1492

C++中boost库boost/foreach.hpp遍历头文件最全总结及与std::for_each区别介绍

目录一、 头文件概述 是 Boost 库中的一个头文件,而不是 C++ 标准库的一部分。它提供了一个名为 的宏,用于简化容器和数组的遍历操作。它既不是模板类也不是模板函数,而是一个宏,旨在使遍历容器和数组的代码更加简洁和易读。使用 可以避免使用迭代器的繁琐操作,提高代码的可读性和可维护性。二、 中的函数和方法概述2.1 宏的基本用法: - : - 这是 宏的基本形式,其中 是迭代变量, 是要遍历的容器或数组。 - 使用场景:当需要遍历容器或数组中的元素,并且不想使用迭代器的传统 循环时使用,能使

行知SLAM 1125

Python爬虫实战:扒取专利数据库核心信息,我用这招搞定反爬+数据结构化(附完整可运行代码)

这套爬虫方案从「实际需求」出发,解决了专利数据库抓取的核心痛点:反爬突破、数据结构化、标题创作。核心价值不在于代码多复杂,而在于「实用」——我用这套代码半天就抓取了800+条Python爬虫相关专利,比手动效率提升了几十倍。最后想说:爬虫技术的核心是「解决问题」,而不是炫技。专利数据能帮我们快速了解行业技术趋势,尤其是程序员,从专利中扒出的核心逻辑,远比零散的博客文章更系统。希望这篇实战分享能帮到有需要的小伙伴,也欢迎在评论区交流专利爬虫的更多技巧!

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2132

使用 boost.foreach foreach

使用 boost.foreach foreach 作者: 江淼 Blog: http://blog.youkuaiyun.com/jiangfriend 时间: 2007-7-28 14:56 用过别的语言的朋友一定深受foreach这个命令所带来方便,可惜C++并没提供,随着1.34.0 boost.foreach正式成为boost的一部分,而且boost.foreach相当的简单易用。从此c

江淼的专栏 8882

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

BOOST_FOREACH用法教程

类似perl和c#的foreach,BOOST_FOREACH给我们带来了一种简单而有效的遍历数组的方式。 让我们首先来看个简单的例子: #include #include #include int main() { std::string hello( "Hello, world!" ); BOOST_FOREACH( char ch, hell

固本培元的专栏 6673

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Boost.Foreach

类似perl和c#的foreach,BOOST_FOREACH给我们带来了一种简单而有效的遍历数组的方式。 让我们首先来看个简单的例子: #include #include #include int main() { std::string hello( "Hello, world!" ); BOOST_FOREACH( char ch, hello ) { std

晴天的专栏 1046

深度学习工具包 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")

boost库BOOST_FOREACH使用说明

简介 boost库BOOST_FOREACH可以用来简化STL容器的迭代操作。 使用示例 #include <boost/foreach.hpp> vector<int> boxes= {1,2,3}; BOOST_FOREACH(int box,boxes) //遍历boxes中每个元素,赋值给box { //这里就可以访问box std::cout <&l...

爱问西瓜爱大树的博客 612

BOOST_FOREACH是不是搞过头了

看看BOOST_FOREACH的实现吧,你真的会为了少敲几个字母,为了代码界面上的简单而使用BOOST_FOREACH吗?///////////////////////////////////////////////////////////////////////////////// BOOST_FOREACH////   For iterating over collections. Col

3660

boost学习之BOOST_FOREACH

成天写迭代器,写的手指都疼,BOOST_FOREACH可以方便的遍历STL容器. 只需要头文件: #include 然后遍历容器vector/list/set/deque/stack/queue都是类似的: vectorint32_t> _v; BOOST_FOREACH(int32_t value,_v) { //这里就可以访问value } 同时元素

WangIcter的专栏 4185

BOOST_FOREACH遍历

C++中繁琐的遍历器,在boost中一个BOOST_FOREACH搞定。#include <iostream> #include <boost/foreach.hpp> #include <vector> using namespace std; using namespace boost;void main() { vector<int> ivec ; for (int i = 0

hscoder的博客 2331

mdl c++API和BOOST_AUTO&BOOST_FOREACH

C++0X已经发布啦,如果你用的是旧编译器,好多东西用不上,如typeof和auto; 我用mdl C++ API还是VS2005,因为不想换别人的机子还带个10.0的运行时过去。 boost中的BOOST_AUTO在旧编译器上也可以使用auto的特性. 在遍历ElementAgenda的时候,才开始,可能不知道是声明一个什么变量,是EditElementHandl还是EditElement

MDLFANS的专栏 2561

boost之foreach

头文件 #include “boost/foreach.hpp” foreach可以用在array, string还有其他stl的容器如vector,list,deque上,形式为 BOOST_FOREACH( 元素, 可迭代对象),还有BOOST_REVERSE_FOREACH(元素类型, 可迭代对象)可以用于反向迭代。 foreach还可以作用于能够返回可迭代对象的函数上。 元素字段可以返回引用

gx_1983的专栏 1536

BOOST_FOREACH 使用及注意事项

BOOST_FOREACH可以简化便利操作。 例如 #include <boost/foreach.hpp> #include <vector> #include <iostream> int main() { std::vector<int> vInt; for(int i = 0; i < 10; i++) { ...

guoguangwu的专栏 767
上一篇: 关于沟通
下一篇: boost::split
lambda_tea
博客等级 码龄15年 1粉丝 16原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值