相关疑难解决方法(0)

C++可以编译内联函数指针吗?

假设我有一个functionProxy带有泛型参数的函数function并调用它operator():

template< typename Function > void functionProxy( Function function ) {
    function();
}
Run Code Online (Sandbox Code Playgroud)

传递给它的对象可能是:


int main( )
{
    functionProxy( Functor() );
    functionProxy( function );
    functionProxy( [](){ std::cout << "lambda!" << std::endl; } );
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译器将能够内联function中 …

c++ compiler-construction optimization inline function

27
推荐指数
1
解决办法
9959
查看次数

C ++中字符串向量的排序向量

我很难弄清楚如何对字符串向量的向量进行排序,这是测试代码。


#include <iostream>
#include <vector>
#include <boost/algorithm/string.hpp>

int main(int argc, char** argv) {
  std::vector <std::vector <std::string> > data_var;
  std::vector <std::string> temp;

  std::string str1 = "1,hello3,temp2";
  std::string str2 = "2,hello2,temp1";
  std::string str3 = "3,hello1,temp3";

  boost::split(temp, str1, boost::is_any_of(","));
  data_var.push_back(temp);
  boost::split(temp, str2, boost::is_any_of(","));
  data_var.push_back(temp);
  boost::split(temp, str3, boost::is_any_of(","));
  data_var.push_back(temp);

  // sorting code here...
}
Run Code Online (Sandbox Code Playgroud)

提前致谢...

c++ sorting vector

3
推荐指数
2
解决办法
9411
查看次数