简体   繁体   English

未定义模板&#39;std :: __ 1 :: function的隐式实例化 <int (double, double, double, double)> “

[英]Implicit instantiation of undefined template 'std::__1::function<int (double, double, double, double)>'

In the project I'm working on, I'm trying to use the curlpp library to make a simple html GET request. 在我正在研究的项目中,我正在尝试使用curlpp库来创建一个简单的html GET请求。 When I pass the cpp file to g++ I get the following errors: 当我将cpp文件传递给g ++时,我收到以下错误:

/usr/local/include/curlpp/internal/CurlHandle.hpp:185:42: error: implicit instantiation of undefined template 'std::__1::function<int (double, double, double, double)>'
curlpp::types::ProgressFunctionFunctor mProgressFunctor;
/usr/local/include/curlpp/internal/CurlHandle.hpp:134:66: error: implicit instantiation of undefined template 'std::__1::function<int (double, double, double, double)>'
void setProgressFunctor(curlpp::types::ProgressFunctionFunctor functor)

I'm pretty new to c++ so any help would be appreciated. 我对c ++很新,所以任何帮助都会受到赞赏。 I'm working on macOS Sierra. 我正在研究macOS Sierra。 I used Homebrew to install curlpp (ie it's located in /usr/local/Cellar). 我使用Homebrew安装curlpp(即它位于/ usr / local / Cellar)。


This is my code: 这是我的代码:

  1 #include <string>
  2 #include <sstream>
  3 #include <iostream>
  4 #include <curlpp/cURLpp.hpp>
  5 #include <curlpp/Easy.hpp>
  6 #include <curlpp/Options.hpp>
  7 
  8 using namespace curlpp::options;
  9 
 10 int main(int, char **)
 11 {   
 12     try 
 13     {   
 14         curlpp::Cleanup testCleanup;
 15         curlpp::Easy miRequest;
 16         miRequest.setOpt<Url>("http://www.wikipedia.org");
 17         miRequest.perform();
 18     }
 19     catch(curlpp::RuntimeError & e)
 20     {   
 21         std::cout << e.what() << std::endl;
 22     }
 23     catch(curlpp::LogicError & e)
 24     {   
 25         std::cout << e.what() << std::endl;
 26     }
 27     
 28     return 0;
 29 }

Just inform the compiler that you would like to use features of the newer C++ standard by adding either -std=c++11 or -std=c++14 to compiler options. 通过向编译器选项添加-std=c++11-std=c++14 ,通知编译器您希望使用较新的C ++标准的功能。 std::function is just one of those things, which did not exist prior to the year 2011. std::function只是其中之一,在2011年之前不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM