zoukankan      html  css  js  c++  java
  • song--! 1109 cpp类

    c11

    一、智能指针

    1a、 头文件 __,三个智能指针__

    1b

    单个数据 智能指针转换能自动释放的,lamda

    DecodeFrame* dfr = new DecodeFrame;

    -->____

    数组智能带自动释放, 并拷贝数据过去

    BYTE* tmpbuf  = new BYTE[640 * 360];

    memcpy(tmpbuf ,videoFrame->data[0],640*360);

    -->__

    二、lambda

    [] () -> int { return 1; }

    也就是

    [captures] (params) -> ret {Statments;}  

    1、ret为什么一般可省略

    2、captures = 和& 表示__

    3、在函数内部一样使用局部变量、成员变量 (不类似于闭包,有生命周期的,thi  label变null)

    4、foreach 用lambda写法

    三、 std::bind  std:bind

     1、头文件

    2、绑定成员函数的方法

     四、 stl去除前后空格

    五 cpp11线程

    //有时间的话看看cpp核心准则

    1a:单个

    std::shared_ptr<DecodeFrame> dfr(static_cast<DecodeFrame*>( new DecodeFrame), [&](DecodeFrame *p) { delete p;});

    数组

     std::shared_ptr<BYTE> tmpbuf (new BYTE[640 * 360],  [](int *p) { delete[] p; } );  //std::default_delete<BYTE[]>()

    memcpy(tmpbuf.get(),videoFrame->data[0],640*360);

    1、 有一个return 就返回了

    2、传值方式和传引用方式

    三、1、<functional>

    2、

    class Test1{
    public:
        void fun(int val){
            cout << "hello world " << val << endl;
        }
    };
    
    
    Test1 t;
    std::function<void(int)> pf = std::bind(&Test1::fun, t, 2);
    pf(4); 

     四

    inline std::string trim(std::string source)
     {
         std::string result = source.erase(source.find_last_not_of(" ") + 1);
         return result.erase(0, result.find_first_not_of(" "));
    
    }

     五、

    std::string ExeVlcCmd(wstring szIperfCmd){
        return "";
    }
    
    thread t(ExeVlcCmd, mycmd);
    t.detach();
  • 相关阅读:
    URAL 2067 Friends and Berries (推理,数学)
    URAL 2070 Interesting Numbers (找规律)
    URAL 2073 Log Files (模拟)
    URAL 2069 Hard Rock (最短路)
    URAL 2068 Game of Nuts (博弈)
    URAL 2066 Simple Expression (水题,暴力)
    URAL 2065 Different Sums (找规律)
    UVa 1640 The Counting Problem (数学,区间计数)
    UVa 1630 Folding (区间DP)
    UVa 1629 Cake slicing (记忆化搜索)
  • 原文地址:https://www.cnblogs.com/cnchengv/p/15529154.html
Copyright © 2011-2022 走看看