+ 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?
2 ответов
+ 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.
+ 1
Thanks Arsenic