I was solving one simple problem with the use of replace_if but every time it gives me error.
Problem:
in a given string remove the adjacent character and make string as compact as possible.
Ex: aabcc will become b and aabbcc will become empty string.
int main()
{
string s;
cin>>s;
replace_if(s.begin(),s.end(),[](char l, char r){return l == r;},"");
cout << string(s.begin(),s.end());
return 0;
}
Error:
/usr/include/c++/6/bits/stl_algo.h:4280:12: note: candidate expects 3 arguments, 2 provided
solution.cc:19:51: note: candidate:
main()::<lambda(char, char)>
replace_if(s.begin(),s.end(),[](char l, char r){