如何使用lower_bound函数与lambda结合使用int值创建结构向量后立即对它进行排序? (1行功能)
vector<test*> v;
val = 10;
test * tmp = new test ( val, "Alex" );
/* something like this :
* auto it = lower_bound ( v . begin (), v . end (), val , [&] ( ) -> bool {} );
*/
v . insert ( it, tmp );
结构:
class test
{
test ( int val , string name ) : val ( val ), name ( name ) { }
int val;
string name;
};