什么是最优雅的方式也修复以下代码:
#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)