Skip to content

Commit a3de1c6

Browse files
committed
osx support
1 parent 985d5ee commit a3de1c6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/hashtable.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "hashtable.h"
22
#include <iostream>
3+
#ifndef __APPLE__
34
#include <unordered_map>
5+
#endif
46

57
using namespace v8;
68

@@ -91,7 +93,7 @@ Handle<Value> HashTable::Put(const Arguments& args) {
9193

9294
Persistent<Value> persistent = Persistent<Value>::New(value);
9395

94-
obj->map.insert(std::pair<std::string, Persistent<Value>>(std::string(*keyStr), persistent));
96+
obj->map.insert(std::pair<std::string, Persistent<Value> >(std::string(*keyStr), persistent));
9597

9698
//Return undefined
9799
return scope.Close(Local<Value>());

src/hashtable.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
#define HASHTABLE_H
33

44
#include <node.h>
5+
#ifdef __APPLE__
6+
#include <tr1/unordered_map>
7+
#define UNORDERED_MAP_TYPE std::tr1::unordered_map
8+
#else
59
#include <unordered_map>
10+
#define UNORDERED_MAP_TYPE std::unordered_map
11+
#endif
612

713
class HashTable : public node::ObjectWrap {
814
public:
@@ -13,7 +19,7 @@ class HashTable : public node::ObjectWrap {
1319
HashTable(size_t buckets);
1420
~HashTable();
1521

16-
typedef std::unordered_map<std::string,v8::Persistent<v8::Value>> MapType;
22+
typedef UNORDERED_MAP_TYPE<std::string,v8::Persistent<v8::Value> > MapType;
1723
MapType map;
1824

1925
//new HashTable() or new HashTable(buckets)

0 commit comments

Comments
 (0)