当前位置:网站首页>One of the usage of operator()
One of the usage of operator()
2022-07-27 06:06:00 【Mr FF】
// operator_callable.cpp
#include <iostream>
using namespace std;
template <typename T>
struct Print {
void operator() (const T& msg) const
{
cout << msg << " ";
}
};
template <typename T, typename Func>
void ForEach(T* begin, T* end, const Func& func)
{
while (begin != end) {
func(*begin++);
}
}
int main(int argc, char **argv)
{
int array[] = {10, 11, 23, 25, 30};
ForEach(array, array + 5, Print<int>{});
return 0;
}Compile implementation
g++ -o operator_callable operator_callable.cpp -std=c++11边栏推荐
猜你喜欢

【Unity URP】代码获取当前URP配置UniversalRendererData,并动态添加RendererFeature

浅记一下十大排序
![[MVC Architecture] MVC model](/img/71/e10da490d5f0098c64b33e77d158e7.png)
[MVC Architecture] MVC model

Weidongshan digital photo frame project learning (IV) simple TXT document display (e-paper book)

安全帽反光衣检测识别数据集和yolov5模型

2022.6.10 STM32MP157串口时钟的学习

Can it replace PS's drawing software?

【11】二进制编码:“手持两把锟斤拷,口中疾呼烫烫烫”?

发布 分辨率0.22m的建筑物分割数据库

制作视频后期特效需要什么工具?
随机推荐
[song] rebirth of me in py introduction training (5): List
What tools are needed to make video post effects?
编程学习记录——递归解决汉诺塔问题
制作视频特效必备工具:NUKE 13
【头歌】重生之我在py入门实训中(9):异常处理
Auto Encoder(AE),Denoising Auto Encoder(DAE), Variational Auto Encoder(VAE) 区别
2022.6.10 stm32mp157 serial port clock learning
子类调用父类构造函数的时机
C语言-程序的编译
11. Gradient derivation of perceptron
IOT operating system
解决conda install 安装停止、中断问题
WebODM win10安装教程(亲测)
Matlab 画图(超详细)
【头歌】重生之我在py入门实训中(6):函数的定义与应用
【11】二进制编码:“手持两把锟斤拷,口中疾呼烫烫烫”?
LaTeX中多个公式公用一个序号时
编程学习记录——第7课【函数】
pytorch转onnx相关问题
Day 2. Depressive symptoms, post-traumatic stress symptoms and suicide risk among graduate students