Using a vector of structs in a struct in c++/cx

一笑奈何 提交于 2019-12-13 02:13:06

问题


I have a header file defining some structs I want to use in my code.

public value struct HttpHeader
{
   Platform::String^ mName;
   Platform::String^ mValue;

};
typedef Platform::Collections::Vector<HttpHeader> HttpHeaders;

public value struct HttpRequestEvent
{
   Platform::String^ mUri;
   HttpHeaders^ mHeaders;
};

When I build this I get this error:

error C3986: 'mHeaders': signature of public member contains native type 'std::equal_to<_Ty>'
      with
      [
          _Ty=cpcpb::HttpHeader
      ] (SettingsServiceImpl.cpp)

What am I missing here? Isn't everything I'm using C++/Cx?


回答1:


Use Windows::Foundation::Collections::IVector instead of Platform::Collections::Vector.

To use Platform::Collections::Vector you have to provide a custom comparator which is the equals operator.

Check this link - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/5ec2090f-b7e6-40e8-9cd7-75cf36d05ab3/



来源:https://stackoverflow.com/questions/11769548/using-a-vector-of-structs-in-a-struct-in-c-cx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!