在在C的结构体使用结构的向量++ / CX(Using a vector of structs in

2019-10-17 02:13发布

我定义一些结构我想在我的代码使用的头文件。

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;
};

当我建立这个我得到这个错误:

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

我缺少的是在这里吗? 不是一切我使用C ++ / CX?

Answer 1:

使用Windows::Foundation::Collections::IVector ,而不是Platform::Collections::Vector

要使用Platform::Collections::Vector你必须提供一个自定义的比较是相等操作符。

检查此链接- http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/5ec2090f-b7e6-40e8-9cd7-75cf36d05ab3/



文章来源: Using a vector of structs in a struct in c++/cx