Compile errors using std::bind in gcc 4.7

后端 未结 2 1849
遥遥无期
遥遥无期 2021-01-16 08:53

I am having a lot of trouble using std::bind in various places of my code. Sometimes it works, sometimes it doesn\'t, so I assume I am doing something fundament

2条回答
  •  Happy的楠姐
    2021-01-16 09:21

    The _2 placeholder means to use second argument of the returned functor. Therefore the type of

    std::bind(foo,1,_2)
    

    is not std::function but

    std::function
    

    To get std::function, use

    std::bind(foo, 1, _1)
    //                ^^
    

提交回复
热议问题