当前位置:网站首页>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;
}

边栏推荐
- 力扣刷题之分数加减运算(每日一题7/27)
- Various minor problems of jupyter notebook, configuration environment, code completion, remote connection, etc
- web-uploader不能多文件上传
- Code speed optimization
- C obtains JSON format data asynchronously from the web address
- How dare you write a resume that is proficient in concurrent programming? Why do you use a two-way linked list in AQS?
- 机器学习【Numpy】
- three.js 第五十四用如何给shader传递结构体数组
- HDU多校第二场 1011 DOS Card
- Rdkit: introduce smiles code, smart code and Morgan fingerprint (ECFP)
猜你喜欢

What if MySQL forgets the password

Simple code implementation of decision tree
![Leetcode 1331 array sequence number conversion [map] the leetcode path of heroding](/img/be/d429d0c437dc5ed7cb4448e223a83a.png)
Leetcode 1331 array sequence number conversion [map] the leetcode path of heroding

KNN method predicts pregnancy, KNN principle simple code

12_ UE4 advanced_ Change a more beautiful character model

Mathematical modeling -- analytic hierarchy process model

Producer consumer model of concurrent model

The Federal Reserve raised interest rates again, Powell "let go of doves" at 75 basis points, and US stocks reveled

MySQL流程控制之while、repeat、loop循环实例分析

04 | background login: login method based on account and password (Part 1)
随机推荐
C obtains JSON format data asynchronously from the web address
Leetcode 1331 array sequence number conversion [map] the leetcode path of heroding
Microcomputer principle operation
Shardingsphere's level table practice (III)
Photo scale correction tool: DxO viewpoint 3 direct mount version
web-uploader不能多文件上传
[freeswitch development practice] unimrcp compilation and installation
年内首个“三连跌” 95号汽油回归“8元时代“
Matlab learning -- structured programs and user-defined functions
exness:鸽派决议帮助黄金反弹,焦点转向美国GDP
Bingbing learning notes: operator overloading -- implementation of date class
Ten thousand words detailed Google play online application standard package format AAB
Minesweeping simple version
Several methods of converting object to string
KNN method predicts pregnancy, KNN principle simple code
LeetCode 1331 数组序号转换[Map] HERODING的LeetCode之路
Whole process record of yolov3 target detection
Summary of basic knowledge points of C language
i. MX 8m plus integrated dedicated neural processing engine (NPU)
July 28, 2022 Gu Yujia's study notes