Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 10804

New Features in for VS 2013 RTM

$
0
0

Introduction:

Hi, I’m Brandon Jacobs, an intern on the Visual C++ Libraries team. For part of my internship, I was tasked with adding new features to Stephan T. Lavavej’s . It was certainly an honor to be one of the few to contribute to . You can find these changes in VS 2013 RTM (these changes are not in 2013 Preview).

 

Summary:

These are the changes I’ve made to :

1.            Added UnorderedMap and UnorderedMapView wrapper classes to .

2.            Added initializer_list constructors to Vector, VectorView, Map, MapView,  UnorderedMap, and UnorderedMapView.

3.            Added validation so that customers use valid WinRT types to instantiate the collections in .

 

Features:

UnorderedMap and UnorderedMapView:

This is the wrapper class for the std::unordered_map class. The functionality is the same as Map and MapView. The only difference is the underlying data structure, which is a hash table instead of a balanced binary tree. So, types must be hashable and must be able to show equality. Just like Map and MapView defaults to std::less,  UnorderedMap and UnorderedMapView defaults to std::hash and std::equal_to. Both the hash and equality predicates are template parameters, so you are allowed to change the actions of UnorderedMap and UnorderedMapView by providing your own predicates.

 

initializer_list constructors:

You can now construct any data structure using the C++11 initializer_list constructors.

An example:

namespace WFC = Windows::Foundation::Collections;

namespace PC = Platform::Collections;

WFC::IVector^ v = ref new PC::Vector{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

WFC::IMap^ m

= ref new PC::Map{ { 1, 10 }, { 2, 20 }, { 3, 30 }, { 4, 40 } };

WFC::IMap^ m2

= ref new PC::UnorderedMap{ { 1, 10 }, { 2, 20 }, { 3, 30 }, { 4, 40 } };

 

Valid WinRT types only:

We now check whether the type you want to store in your given data structure is a valid WinRT type. Currently if you have:

PC::Vector

You will get an odd compiler error. Now we check whether the types passed in are valid WinRT types. If this check fails, you will now get a much nicer compiler error that even includes the line in which you tried to create a collection with an invalid type.

Only the items that will appear in the Windows::Foundation::Collections interfaces need to be valid WinRT types. Predicates such as std::less, std::hash, etc. are not passed into the Windows::Foundation::Collections interfaces, so they are not affected by that restriction.

Valid WinRT types are:

  1. integers
  2. interface class ^
  3. public ref class^
  4. value struct
  5. public enum class

 

Thank you for taking the time and reading this post,

Brandon Jacobs

SDE Intern – Visual C++ Libraries


Viewing all articles
Browse latest Browse all 10804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>