question

MRUTYUNJAYAMAHAPATRA-6389 avatar image
0 Votes"
MRUTYUNJAYAMAHAPATRA-6389 asked RLWA32-6355 commented

_Pairib is not working with std::set


Hi

I am trying to migrate my project from vs2017 to vs2019. I was using _Pairib with std::set with vs2017 . but it is not working vs 2019.

Can anybody please suggest replacement for _Pairib in vs2019 or How can I use it in vs2019..

typedef std::set< CNewAIPObject*, CNewAIPObjectPtrNameCmp > NewAIPObjPtrSet;
typedef NewAIPObjPtrSet::_Pairib NewAIPObjPtrSetPIB;


Best Regards
Mrutyunjaya

windows-wpfc++vs-generalwindows-10-network
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RLWA32-6355 avatar image
1 Vote"
RLWA32-6355 answered RLWA32-6355 commented
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I would like to know how can I use Pair in case of a template set. As per example below..

set<int, greater<int> > s1;


 // insert elements in random order
 s1.insert(40);
 s1.insert(30);
 s1.insert(60);
 s1.insert(20);
 s1.insert(50);
 
 // printing set s1
 set<int, greater<int> >::iterator itr;

How can I use Pair incase of above example ..

0 Votes 0 ·
RLWA32-6355 avatar image RLWA32-6355 MRUTYUNJAYAMAHAPATRA-6389 ·

You don't need std::pair to print the contents of the above set.

     set<int, greater<int>> s1;
     s1.insert(40);
     s1.insert(30);
     s1.insert(60);
     s1.insert(20);
     s1.insert(50);
    
     for (auto& x : s1)
         cout << x << endl;
    
     for (set<int, greater<int>>::iterator i = s1.begin(); i != s1.end(); i++)
     {
         cout << *i << endl;
     }
0 Votes 0 ·

I would like to thank you for your reply .
s
Set<int, greater<int>> s1;
s1.insert(40);

Suppose I have one element in set then I may not need for loop for (auto& x : s1) .

In that case how can I check like pair.. I mean Pair.first and Pair.second..

0 Votes 0 ·
Show more comments