当前位置:网站首页>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边栏推荐
猜你喜欢

Pix2Pix原理解析

Xmind 思维导图 2022 v12.0.3中文版更新了哪些内容?

PS 2022 updated in June, what new functions have been added

2022.6.10 STM32MP157串口时钟的学习

【5·20特辑】MatLAb之我在和你表白

11. Gradient derivation of perceptron
![[high concurrency] interviewer](/img/50/baa662cb4ce30cf2ef4cb5952960dd.jpg)
[high concurrency] interviewer

Super remote connection management tool: Royal TSX

面试常问Future、FutureTask和CompletableFuture

STM32-FSMC外扩内存SRAM
随机推荐
编程学习记录——第5课【分支和循环语句】
[first song] deep learning of rebirth -keras (elementary)
What has been updated in the Chinese version of XMIND mind map 2022 v12.0.3?
常见的SQL优化方法
谈谈为何需要将类的成员函数声明为private
力扣题解 动态规划(4)
2022.6.10 stm32mp157 serial port clock learning
个人开发者申请代码签名证书的签发流程
Baiwen driving Daquan learning (II) I2C driving
LaTeX中多个公式公用一个序号时
【头歌】重生之我在py入门实训中(8): 模块
C语言-动态内存管理
Weidongshan digital photo frame project learning (I) display ASCII characters on LCD
力扣第一周错题集
文件的路径
制作视频特效必备工具:NUKE 13
【头歌】重生之我在py入门实训中(3): if条件语句
Stm32-fsmc extended memory SRAM
子类调用父类构造函数的时机
geonode geoserver win10 安装教程(亲测)