zoukankan      html  css  js  c++  java
  • 函数对象适配器之ptr_fun的使用示例

     1 //============================================================================
     2 // Name        : CopyInts4.cpp
     3 // Author      : motein
     4 // Version     :
     5 // Copyright   : Your copyright notice
     6 // Description : Hello World in C++, Ansi-style
     7 //============================================================================
     8 
     9 #include <iostream>
    10 #include <algorithm>
    11 #include <vector>
    12 using namespace std;
    13 
    14 int u_func(int a)
    15 {
    16     int ret = a;
    17     return ret;
    18 }
    19 
    20 int b_func(int a,int b)
    21 {
    22     return a+b;
    23 }
    24 
    25 void call()
    26 {
    27     pointer_to_unary_function<int,int> uf(u_func);
    28     cout << uf(100) << endl;
    29 
    30     pointer_to_binary_function<int,int,int> bf(b_func);
    31     cout << bf(111,222) << endl;
    32 
    33     cout << ptr_fun(u_func)(100) << endl;
    34     cout << ptr_fun(b_func)(111,222) << endl;
    35 
    36 }
    37 
    38 int main()
    39 {
    40     call();
    41     return 0;
    42 }
  • 相关阅读:
    二进制回复操作
    日志和备份介绍
    mraiadb查
    mraiadb增三删改
    mardb基本操作
    redis搭建主从和多主
    ldd 查看符号找不到
    一个声明指定了多个类型
    word中为选定文本加边框和底纹
    ue配置lua语法高亮
  • 原文地址:https://www.cnblogs.com/AmitX-moten/p/3712198.html
Copyright © 2011-2022 走看看