当前位置:网站首页>operator() 用法之一
operator() 用法之一
2022-07-27 05:19: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;
}编译执行
g++ -o operator_callable operator_callable.cpp -std=c++11边栏推荐
猜你喜欢

Social media user level psychological stress detection based on deep neural network

3. Classification problems - initial experience of handwritten digit recognition

Day 7. Towards Preemptive Detection of Depression and Anxiety in Twitter

DSGAN退化网络

19.上下采样与BatchNorm

11.感知机的梯度推导

10. Gradient, activation function and loss

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

15. GPU acceleration, Minist test practice and visdom visualization

Digital image processing -- Chapter 9 morphological image processing
随机推荐
Day 7. Towards Preemptive Detection of Depression and Anxiety in Twitter
【高并发】面试官
Gbase 8C - SQL reference 4 character set support
常用adb命令汇总 性能优化
【好文种草】根域名的知识 - 阮一峰的网络日志
10. Gradient, activation function and loss
12. Optimization problem practice
Emoji Emoji for text emotion analysis -improving sentimental analysis accuracy with Emoji embedding
Day 15. Deep learning radiomics can predict axillary lymphnode status in early-stage breast cancer
[concurrent programming series 9] priorityblockingqueue, delayqueue principle analysis of blocking queue
socket编程二:使用select
视觉横向课题bug1:FileNotFoundError: Could not find module ‘MvCameraControl.dll‘ (or one of it
pytorch模型
DSGAN退化网络
【Unity URP】代码获取当前URP配置UniversalRendererData,并动态添加RendererFeature
【mysql学习】8
GBASE 8C——SQL参考6 sql语法(2)
Only one looper may be created per thread
Chrome 如何快速将一组正在浏览的网页(tabs)转移到另一台设备(电脑)上
rk3399 gpio口 如何查找是哪个gpio口