Reputation: 20471
Im fairly new to C++ so sorry if this is obvious, but I cannot access the property 'Size' on the type Windows::UI::Xaml::Controls::ItemCollection.
Here is my code:
Windows::UI::Xaml::Controls::ItemCollection& items = Items(); // Items in a property of Windows::UI::Xaml::Controls::GridView which my class derives from
auto count = items.Size(); // -> build error
The error is 'winrt::impl::consume_Windows_Foundation_Collections_IVector::Size': a function that returns 'auto' cannot be used before it is defined
I know that ItemCollection has a Size property, so why is the compiler complaining that it isnt defined.
Any help would be really appreciated
Thanks
Upvotes: 0
Views: 95
Reputation: 51497
You forgot to include a header file that provides the definition of the template, probably <winrt/Windows.Foundation.Collections.h
. This particular compiler error used to be a linker error, that was a lot harder to interpret.
Raymond Chen blogged about the changes that went into C++/WinRT to 'promote' this linker error into a compiler error: Why does my C++/WinRT project get errors of the form “consume_Something: function that returns ‘auto’ cannot be used before it is defined”?
Upvotes: 2