当前位置:网站首页>for_ Example of each usage
for_ Example of each usage
2022-07-29 03:26:00 【3D vision workshop】
List of articles
Preface
Due to accidental discovery for_each Can avoid using for loop , Greatly simplified the code . Here is a simple record of for_each A simple example of demo, Convenient review .
Example demo
#include <iostream>
#include "vector"
#include "algorithm"
void myfunc1(int i)
{
std::cout << i << " ";
}
int main() {
std::vector<int> arr{
3, 4, 2, 6, 5, 1 };
std::cout << "based on for_each, print the vector\n";
for_each(arr.begin(), arr.end(), myfunc1);
std::cout << "\n";
std::cout << "based on lambda, print the vector\n";
for_each(arr.begin(), arr.end(), [](const auto &i){
std::cout << i << " ";});
return 0;
}

边栏推荐
- 如何判定是stun协议
- Redis之sentinel哨兵集群怎么部署
- Learn exkmp again (exkmp template)
- Leetcode 1331 array sequence number conversion [map] the leetcode path of heroding
- Mathematical modeling -- analytic hierarchy process model
- Shardingsphere's level table practice (III)
- 数字孪生实际应用案例-智慧能源篇
- Rongyun real-time community solution
- Matlab learning - accumulation of small knowledge points
- Score addition and subtraction of force deduction and brushing questions (one question per day 7/27)
猜你喜欢

During the year, the first "three consecutive falls" of No. 95 gasoline returned to the "8 Yuan era"“

Unity game special effects

数字图像处理 第10章——图像分割

Example analysis of while, repeat and loop loops in MySQL process control

Multi level wavelet CNN for image restoration

Rongyun IM & RTC capabilities on new sites

MYCAT read / write separation configuration

Asynchronous callback future mode of concurrent mode

MySQL installation and configuration super detailed tutorial and simple database and table building method
![LeetCode 1331 数组序号转换[Map] HERODING的LeetCode之路](/img/be/d429d0c437dc5ed7cb4448e223a83a.png)
LeetCode 1331 数组序号转换[Map] HERODING的LeetCode之路
随机推荐
Principle knowledge is useful
HDU multi School Game 2 1011 DOS card
Multi level wavelet CNN for image restoration
Rdkit: introduce smiles code, smart code and Morgan fingerprint (ECFP)
[freeswitch development practice] media bug obtains call voice flow
Asynchronous callback future mode of concurrent mode
web-uploader不能多文件上传
3.2 model saving and loading
VISO fast rendering convolution block
Environment configuration stepping pit during colab use
Learn more than 4000 words, understand the problem of this pointing in JS, and handwrite to realize call, apply and bind
Ten thousand words detailed Google play online application standard package format AAB
基于单片机烟雾温湿度甲醛监测设计
军品三大基线(功能基线、分配基线、产品基线)及基线包含的文件
RTP 发送 和接收 h265
Numpy acceleration -- > cupy installation
军品技术文件划分及说明
Suffix automata (SAM) board from Jly
i. MX 8m plus integrated dedicated neural processing engine (NPU)
Introduction and advanced MySQL (XIV)