Last active
December 26, 2015 09:19
-
-
Save danslo/7128754 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/windows/glog/stl_logging.h | |
=================================================================== | |
diff --git a/src/windows/glog/stl_logging.h b/src/windows/glog/stl_logging.h | |
--- a/src/windows/glog/stl_logging.h (revision 133) | |
+++ b/src/windows/glog/stl_logging.h (revision 134) | |
@@ -38,6 +38,15 @@ | |
// LOG(INFO) << "data: " << x; | |
// vector<int> v1, v2; | |
// CHECK_EQ(v1, v2); | |
+// | |
+// If you want to use this header file with hash_compare maps or slist, you | |
+// need to define macros before including this file: | |
+// | |
+// - GLOG_STL_LOGGING_FOR_UNORDERED - <unordered_map> and <unordered_set> | |
+// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - <tr1/unordered_(map|set)> | |
+// - GLOG_STL_LOGGING_FOR_EXT_HASH - <ext/hash_(map|set)> | |
+// - GLOG_STL_LOGGING_FOR_EXT_SLIST - <ext/slist> | |
+// | |
#ifndef UTIL_GTL_STL_LOGGING_INL_H_ | |
#define UTIL_GTL_STL_LOGGING_INL_H_ | |
@@ -54,9 +63,21 @@ | |
#include <utility> | |
#include <vector> | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_UNORDERED | |
+# include <unordered_map> | |
+# include <unordered_set> | |
+#endif | |
+ | |
+#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED | |
+# include <tr1/unordered_map> | |
+# include <tr1/unordered_set> | |
+#endif | |
+ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
# include <ext/hash_set> | |
# include <ext/hash_map> | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST | |
# include <ext/slist> | |
#endif | |
@@ -84,7 +105,7 @@ | |
OUTPUT_TWO_ARG_CONTAINER(std::vector) | |
OUTPUT_TWO_ARG_CONTAINER(std::deque) | |
OUTPUT_TWO_ARG_CONTAINER(std::list) | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST | |
OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist) | |
#endif | |
@@ -113,7 +134,15 @@ | |
OUTPUT_FOUR_ARG_CONTAINER(std::map) | |
OUTPUT_FOUR_ARG_CONTAINER(std::multimap) | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_UNORDERED | |
+OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) | |
+OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED | |
+OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set) | |
+OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set) | |
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset) | |
#endif | |
@@ -128,7 +157,15 @@ | |
return out; \ | |
} | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_UNORDERED | |
+OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) | |
+OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED | |
+OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map) | |
+OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map) | |
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap) | |
#endif | |
Index: src/glog/stl_logging.h.in | |
=================================================================== | |
diff --git a/src/glog/stl_logging.h.in b/src/glog/stl_logging.h.in | |
--- a/src/glog/stl_logging.h.in (revision 133) | |
+++ b/src/glog/stl_logging.h.in (revision 134) | |
@@ -34,6 +34,15 @@ | |
// LOG(INFO) << "data: " << x; | |
// vector<int> v1, v2; | |
// CHECK_EQ(v1, v2); | |
+// | |
+// If you want to use this header file with hash maps or slist, you | |
+// need to define macros before including this file: | |
+// | |
+// - GLOG_STL_LOGGING_FOR_UNORDERED - <unordered_map> and <unordered_set> | |
+// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - <tr1/unordered_(map|set)> | |
+// - GLOG_STL_LOGGING_FOR_EXT_HASH - <ext/hash_(map|set)> | |
+// - GLOG_STL_LOGGING_FOR_EXT_SLIST - <ext/slist> | |
+// | |
#ifndef UTIL_GTL_STL_LOGGING_INL_H_ | |
#define UTIL_GTL_STL_LOGGING_INL_H_ | |
@@ -50,9 +59,21 @@ | |
#include <utility> | |
#include <vector> | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_UNORDERED | |
+# include <unordered_map> | |
+# include <unordered_set> | |
+#endif | |
+ | |
+#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED | |
+# include <tr1/unordered_map> | |
+# include <tr1/unordered_set> | |
+#endif | |
+ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
# include <ext/hash_set> | |
# include <ext/hash_map> | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST | |
# include <ext/slist> | |
#endif | |
@@ -80,7 +101,7 @@ | |
OUTPUT_TWO_ARG_CONTAINER(std::vector) | |
OUTPUT_TWO_ARG_CONTAINER(std::deque) | |
OUTPUT_TWO_ARG_CONTAINER(std::list) | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST | |
OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist) | |
#endif | |
@@ -109,7 +130,15 @@ | |
OUTPUT_FOUR_ARG_CONTAINER(std::map) | |
OUTPUT_FOUR_ARG_CONTAINER(std::multimap) | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_UNORDERED | |
+OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) | |
+OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED | |
+OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set) | |
+OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set) | |
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset) | |
#endif | |
@@ -124,7 +153,15 @@ | |
return out; \ | |
} | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_UNORDERED | |
+OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) | |
+OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED | |
+OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map) | |
+OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap) | |
+#endif | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map) | |
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap) | |
#endif | |
Index: src/stl_logging_unittest.cc | |
=================================================================== | |
diff --git a/src/stl_logging_unittest.cc b/src/stl_logging_unittest.cc | |
--- a/src/stl_logging_unittest.cc (revision 133) | |
+++ b/src/stl_logging_unittest.cc (revision 134) | |
@@ -31,6 +31,14 @@ | |
#ifdef HAVE_USING_OPERATOR | |
+#ifdef __GNUC__ | |
+// C++0x isn't enabled by default. | |
+// # define GLOG_STL_LOGGING_FOR_UNORDERED | |
+# define GLOG_STL_LOGGING_FOR_TR1_UNORDERED | |
+# define GLOG_STL_LOGGING_FOR_EXT_HASH | |
+# define GLOG_STL_LOGGING_FOR_EXT_SLIST | |
+#endif | |
+ | |
#include "glog/stl_logging.h" | |
#include <iostream> | |
@@ -39,16 +47,11 @@ | |
#include <string> | |
#include <vector> | |
-#ifdef __GNUC__ | |
-# include <ext/hash_map> | |
-# include <ext/hash_set> | |
-#endif | |
- | |
#include "glog/logging.h" | |
#include "googletest.h" | |
using namespace std; | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
using namespace __gnu_cxx; | |
#endif | |
@@ -83,7 +86,7 @@ | |
CHECK_EQ(m, copied_m); // This must compile. | |
} | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
{ | |
// Test a hashed simple associative container. | |
hash_set<int> hs; | |
@@ -98,7 +101,7 @@ | |
} | |
#endif | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
{ | |
// Test a hashed pair associative container. | |
hash_map<int, string> hm; | |
@@ -145,7 +148,7 @@ | |
CHECK_EQ(m, copied_m); // This must compile. | |
} | |
-#ifdef __GNUC__ | |
+#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH | |
{ | |
// Test a hashed simple associative container. | |
// Use a user defined hash function. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment