开发者

"__comp cannot be used as a function" c++ while trying next_permutation

开发者 https://www.devze.com 2023-02-19 06:06 出处:网络
I\'m trying to do permutations with next_permutation from the stl, however I\'m getting an error and I can\'t figure out how to fix it. I\'ve tried googling, however the only results that come up are

I'm trying to do permutations with next_permutation from the stl, however I'm getting an error and I can't figure out how to fix it. I've tried googling, however the only results that come up are when people used the same function and function's variables name but thats not the case here.

Here's the error :

'__comp' cannot be used as a function

Here's the code :

struct rectangle{
    int n;
    int h;
    int w;
};

bool check(const rectangle& rect1,const rectangle& rect2){
    return rect1.n < rect2.n;
}

do{
//...
} while ( next_permutation(recs.begin(), recs.end(), check) ); // Getting error on this line开发者_开发知识库.

Here's the full source code along with the sample input in case it's needed http://pastebin.com/eNRNCuTf


H = rec4.w + max(rec1.h, rec2.h, rec3.h);

You don't want to pass rec3.h there - The error message simply say that the 3rd argument to max can't be used as a function. I believe you intended:

H = rec4.w + max(max(rec1.h, rec2.h), rec3.h);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号