make cmakefile to compatiable with g++-4.6 and 4.7

This commit is contained in:
wyy 2013-11-07 04:36:36 -08:00
parent 910a368afb
commit 4e838de2b9
4 changed files with 7 additions and 77 deletions

View File

@ -1,2 +1,3 @@
PROJECT(CPPJIEBA)
ADD_DEFINITIONS(-std=c++0x -O3)
ADD_SUBDIRECTORY(src)

View File

@ -213,7 +213,7 @@ namespace Husky
addrSock.sin_port=htons(nPort);
addrSock.sin_addr.s_addr=htonl(INADDR_ANY);
int retval;
retval=bind(sock,(sockaddr*)&addrSock,sizeof(sockaddr));
retval = ::bind(sock,(sockaddr*)&addrSock,sizeof(sockaddr));
if(SOCKET_ERROR==retval)
{
LogError("error [%s]", strerror(errno));

View File

@ -12,84 +12,13 @@
#include <iostream>
#include <sstream>
#include <tr1/unordered_map>
#define HashMap std::tr1::unordered_map
#include <unordered_map>
#define HashMap std::unordered_map
namespace Limonp
{
using namespace std;
//template <typename T>
// string setToString(const set<T>& st)
// {
// if(st.empty())
// {
// return "{}";
// }
// stringstream ss;
// ss<<'{';
// typename set<T>::const_iterator it = st.begin();
// ss<<*it;
// it++;
// while(it != st.end())
// {
// ss<<", "<<*it;
// it++;
// }
// ss<<'}';
// return ss.str();
// }
//template<typename T1, typename T2>
// string mapToString(const map<T1, T2>& mp)
// {
// if(mp.empty())
// {
// return "{}";
// }
// stringstream ss;
// ss<<'{';
// typename map<T1, T2>::const_iterator it = mp.begin();
// ss<<it->first<<": "<<it->second;
// it++;
// while(it != mp.end())
// {
// ss<<", "<<it->first<<": "<<it->second;
// it++;
// }
// ss<<'}';
// return ss.str();
// }
//template<typename T1, typename T2>
// string HashMapToString(const HashMap<T1, T2>& mp)
// {
// if(mp.empty())
// {
// return "{}";
// }
// stringstream ss;
// ss<<'{';
// typename HashMap<T1, T2>::const_iterator it = mp.begin();
// ss<<it->first<<": "<<it->second;
// it++;
// while(it != mp.end())
// {
// ss<<", "<<it->first<<": "<<it->second;
// it++;
// }
// ss<<'}';
// return ss.str();
// }
//template<typename T1, typename T2>
// string pairToString(const pair<T1, T2>& p)
// {
// stringstream ss;
// ss<<p.first<<":"<<p.second;
// return ss.str();
// }
template<class kT, class vT>
vT getMap(const map<kT, vT>& mp, const kT & key, const vT & defaultVal)
{

View File

@ -1,7 +1,7 @@
#ifndef LIMONP_STD_OUTBOUND_H
#define LIMONP_STD_OUTBOUND_H
#include <tr1/unordered_map>
#include "map_functs.hpp"
#include <map>
#include <set>
@ -59,14 +59,14 @@ namespace std
return os;
}
template<class T1, class T2>
ostream& operator << (ostream& os, const std::tr1::unordered_map<T1, T2>& mp)
ostream& operator << (ostream& os, const HashMap<T1, T2>& mp)
{
if(mp.empty())
{
return os << "{}";
}
os<<'{';
typename std::tr1::unordered_map<T1, T2>::const_iterator it = mp.begin();
typename HashMap<T1, T2>::const_iterator it = mp.begin();
os<<*it;
it++;
while(it != mp.end())