小编Kos*_*lek的帖子

为一对中的一个元素提供少于运算符

什么是最优雅的方式也修复以下代码:

#include <vector>
#include <map>
#include <set>
using namespace std;

typedef map< int, int > row_t;
typedef vector< row_t > board_t;
typedef row_t::iterator area_t;

bool operator< ( area_t const& a, area_t const& b ) {
    return( a->first < b->first );
};

int main( int argc, char* argv[] )
{
    int row_num;
    area_t it;

    set< pair< int, area_t > > queue;
    queue.insert( make_pair( row_num, it ) ); // does not compile
};
Run Code Online (Sandbox Code Playgroud)

修复它的一种方法是将less <to namespace命名为std(我知道,   你不应该这样做.)

namespace std {
    bool …
Run Code Online (Sandbox Code Playgroud)

c++ stl operators operator-keyword

6
推荐指数
1
解决办法
2401
查看次数

标签 统计

c++ ×1

operator-keyword ×1

operators ×1

stl ×1