Support building without TR1.

Change-Id: Ib59e201198e1ff2621626ab80e6b6f2156f0d1d1
diff --git a/internal/ceres/collections_port.h b/internal/ceres/collections_port.h
index 88032a5..a356cc0 100644
--- a/internal/ceres/collections_port.h
+++ b/internal/ceres/collections_port.h
@@ -33,17 +33,41 @@
 #ifndef CERES_INTERNAL_COLLECTIONS_PORT_H_
 #define CERES_INTERNAL_COLLECTIONS_PORT_H_
 
-#if defined(_MSC_VER) && _MSC_VER <= 1600
-#include <unordered_map>
-#include <unordered_set>
+#if defined(CERES_NO_TR1)
+#  include <map>
+#  include <set>
 #else
-#include <tr1/unordered_map>
-#include <tr1/unordered_set>
+#  if defined(_MSC_VER) && _MSC_VER <= 1600
+#    include <unordered_map>
+#    include <unordered_set>
+#  else
+#    include <tr1/unordered_map>
+#    include <tr1/unordered_set>
+#  endif
 #endif
 #include <utility>
 #include "ceres/integral_types.h"
 #include "ceres/internal/port.h"
 
+// Some systems don't have access to TR1. In that case, substitute the hash
+// map/set with normal map/set. The price to pay is slightly slower speed for
+// some operations.
+#if defined(CERES_NO_TR1)
+
+namespace ceres {
+namespace internal {
+
+template<typename K, typename V>
+struct HashMap : map<K, V> {};
+
+template<typename K>
+struct HashSet : set<K> {};
+
+}  // namespace internal
+}  // namespace ceres
+
+#else
+
 namespace ceres {
 namespace internal {
 
@@ -138,4 +162,6 @@
 
 CERES_HASH_NAMESPACE_END
 
+#endif  // CERES_NO_TR1
+
 #endif  // CERES_INTERNAL_COLLECTIONS_PORT_H_
diff --git a/internal/ceres/schur_ordering.cc b/internal/ceres/schur_ordering.cc
index 2fe1080..0654724 100644
--- a/internal/ceres/schur_ordering.cc
+++ b/internal/ceres/schur_ordering.cc
@@ -39,6 +39,8 @@
 #include "ceres/residual_block.h"
 #include "glog/logging.h"
 
+#if !defined(CERES_NO_TR1)
+
 CERES_HASH_NAMESPACE_START
 
 // Allow us to hash pointers as if they were int's
@@ -50,6 +52,8 @@
 
 CERES_HASH_NAMESPACE_END
 
+#endif
+
 namespace ceres {
 namespace internal {