decltype() to extract element type from a container object #DeepakCM

set<int> const abundance({11,22,33,44,55});
//set<char> const abundance({‘a’,’b’,’c’,’d’,’e’});

vector<decltype(abundance)::value_type> letters; //whatever the element type in “abundance”, the vector will use the same type 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s