当前位置:网站首页>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边栏推荐
猜你喜欢
随机推荐
Lightroom Classic 2022 v11.4中文版「最新资源」
Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis
[song] rebirth of me in py introductory training (10): numpy
IOT operating system
能替代ps的修图软件?
Greedy high performance neural network and AI chip application research and training
[song] rebirth of me in py introductory training (9): exception handling
A photo breaks through the face recognition system: you can nod your head and open your mouth, netizens
Gbase 8C - SQL reference 6 SQL syntax (14)
【Unity URP】代码获取当前URP配置UniversalRendererData,并动态添加RendererFeature
力扣题解 动态规划(3)
[first song] rebirth of me in py introductory training (2): formula programming
【第一篇博客-展望】
C language - linear sequence table
李宏毅 2020 深度学习与人类语言处理 DLHLP-Conditional Generation by RNN and Attention-p22
[song] rebirth of me in py introduction training (5): List
LaTeX中多个公式公用一个序号时
判断是否为回文结构的三种方法
[first song] deep learning of rebirth -keras (elementary)
c语言-线性顺序表

![[Haowen planting grass] knowledge of root domain name - Ruan Yifeng's Weblog](/img/75/8f41db9f9c077b43751d63b7b5b57e.png)


![[first song] machine learning of rebirth - linear regression](/img/70/3efd9eacf88f55022eb52d096926f7.png)




