function<bool(const pair<int, int>&, const pair<int, int>&)> cmp = [](const pair<int, int> & left, const pair<int, int> & right){if(left > right) return true;}; //multiset<pair<int, int>, function<bool(const pair<int, int>&, const pair<int, int>&)> mt(cmp); multiset<pair<int, int>, decltype(cmp)> mt1(cmp); cout<<typeid(decltype(cmp)).name()<<endl<<typeid(cmp).name()<<endl;
the comment code(mt
) make error whereas line below(mt1
) won't.
i tried cout
name of 2 type , same.
besides, tried this:
multiset<pair<int, int>, const function<bool(const pair<int, int>&, const pair<int, int>&) &> mt(cmp);
or
multiset<pair<int, int>, function<bool(const pair<int, int>&, const pair<int, int>&) &> mt(cmp);
all of them don't work.
so type of second argument exactly? if don't use decltype
, how can declare it?
look @ code, lost >
.
multiset<pair<int, int>, function<bool(const pair<int, int>&, const pair<int, int>&)>> mt(cmp); // ~
using decltype
should idea.
btw: should return when if
returns false
in lambda. or return left > right;
.
Comments
Post a Comment