+ 1

What is need of custom comparator post object name of map

Hi Refer code below: https://code.sololearn.com/c6WexWpRFRa3 refer line #35 from function void testComparator() as below: map<test,int,decltype(comparator)> m(comparator); I understand that map template has three argument and hence map<test,int,decltype(comparator)> is ok for me to understand. What is meaning of m(comparator)? I mean why comparator is passed to object?

9th Mar 2022, 4:15 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Réponses
+ 2
When you not pass the lambda as a parameter, it will try to create one ( using default constructor of decltype(comparator) ) which is not possible as lambdas doesn't have any default constructors.
12th Mar 2022, 1:12 AM
Arsenic
Arsenic - avatar
+ 1
Thanks Arsenic
12th Mar 2022, 7:20 AM
Ketan Lalcheta
Ketan Lalcheta - avatar