locked
Cannot use Platform::Collections::Vector in WinRT method signature

    Question

  • When I try to make a public method with a WinRT Vector, I get an error:

    void setVector(Platform::Collections::Vector<Platform::String^>^);

    error C3986: 'setVector': signature of member contains native type 'std::equal_to<_Ty>'

    I can write my own template class which uses a Vector on the inside.

    template <typename T> public ref class MyTemplateClass sealed
    {
    public:
    	MyTemplateClass(void){myVector = ref new Platform::Collections::Vector<T>();}
    	~MyTemplateClass(void){}
    	T GetAt(unsigned int i){return myVector->GetAt(i);}
    	void SetAt(unsigned int index, T item){myVector->SetAt(index, item);}
    	void Append(T item){myVector->Append(item);}
    private:
    	Platform::Collections::Vector<T>^ myVector;
    };

    then use

    void setVector(MyTemplateClass<Platform::String^>^);

    But this seems rather silly, no?

    One more observation. This:

    template <typename X> public ref class MyOtherClass sealed
    {
    public:
    	MyOtherClass(void){}
    	~MyOtherClass(void){}
    	void setVector(Platform::Collections::Vector<Platform::String^>^ vector);
    };

    compiles.  This:

    public ref class MyOtherClass sealed
    {
    public:
    	MyOtherClass(void){}
    	~MyOtherClass(void){}
    	void setVector(Platform::Collections::Vector<Platform::String^>^ vector);
    };

    gives the same C3986 error.  What's the real difference?  Both seem like a valid use.

    Thursday, March 29, 2012 12:48 AM

Answers

All replies