1

我有一个看起来像这样的代码:

void handle_get(http_request request)
{
   TRACE(L"\nhandle GET\n");

   std::vector< std::pair< utility::string_t, json::value > > answer;

   for(auto const & p : dictionary)
   {
      answer.push_back(std::make_pair(p.first, json::value(p.second)));
   }

   request.reply(status_codes::OK, json::value::object(answer));
};

我得到一个

undefined reference to `web::json::value::object(std::vector<std::pair<std::string, web::json::value>, std::allocator<std::pair<std::string, web::json::value> > >, bool)'

我不明白为什么它没有看到answer没有std::string


std::map< utility::string_t, utility::string_t > dictionary;

我不明白为什么它没有看到object(std::vector< std::pair< utility::string_t, json::value > >)(我已经包含cpprest/json.h)的定义?

4

1 回答 1

4

I do not understand why doesn't it see that answer has no std::string?

Obviously utility::string_t is a typedef for std::string and the compiler is showing the real type, not the typedef name (although in this case the real name is std::basic_string<char>, but the compiler has a special rule to show that as the more common name std::string).

于 2015-03-03T13:18:54.737 回答