Fix handling of unordered_map/unordered_set on OSX 10.9.0.

Depending on the compiler + standard library combination,
unordered_map/set may or may not be available. If available
they maybe in the std or the std::tr1 namespaces.

Apple switched to using libc++ with 10.9.0 which places
unordered_map in std, breaking our assumptions about the
platform.

This change refactors our logic for dealing with the namespace
switching, making it a three state thing rather than two. There
are three defines now, CERES_NO_UNORDERED_MAP, CERES_STD_UNORDERED_MAP
and CERES_TR1_UNORDERED_MAP. Earlier the first two were conflated
into one, leading to the breakage.

Change-Id: I904fe8c49529169bdefa9f2ee6d629e7eab0b855
diff --git a/internal/ceres/collections_port.h b/internal/ceres/collections_port.h
index 715c975..ae71e54 100644
--- a/internal/ceres/collections_port.h
+++ b/internal/ceres/collections_port.h
@@ -33,26 +33,30 @@
 #ifndef CERES_INTERNAL_COLLECTIONS_PORT_H_
 #define CERES_INTERNAL_COLLECTIONS_PORT_H_
 
-#if defined(CERES_NO_TR1)
+#if defined(CERES_NO_UNORDERED_MAP)
 #  include <map>
 #  include <set>
-#else
-#  if defined(_MSC_VER)
-#    include <unordered_map>
-#    include <unordered_set>
-#  else
-#    include <tr1/unordered_map>
-#    include <tr1/unordered_set>
-#  endif
 #endif
+
+#if defined(CERES_TR1_UNORDERED_MAP)
+#  include <tr1/unordered_map>
+#  include <tr1/unordered_set>
+#endif
+
+#if defined(CERES_STD_UNORDERED_MAP)
+#  include <unordered_map>
+#  include <unordered_set>
+#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)
+// Some systems don't have access to unordered_map/unordered_set. 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_UNORDERED_MAP)
 
 namespace ceres {
 namespace internal {
@@ -71,11 +75,19 @@
 namespace ceres {
 namespace internal {
 
+#if defined(CERES_TR1_UNORDERED_MAP)
 template<typename K, typename V>
 struct HashMap : std::tr1::unordered_map<K, V> {};
-
 template<typename K>
 struct HashSet : std::tr1::unordered_set<K> {};
+#endif
+
+#if defined(CERES_STD_UNORDERED_MAP)
+template<typename K, typename V>
+struct HashMap : std::unordered_map<K, V> {};
+template<typename K>
+struct HashSet : std::unordered_set<K> {};
+#endif
 
 #if defined(_WIN32) && !defined(__MINGW64__) && !defined(__MINGW32__)
 #define GG_LONGLONG(x) x##I64
@@ -162,6 +174,5 @@
 
 CERES_HASH_NAMESPACE_END
 
-#endif  // CERES_NO_TR1
-
+#endif  // CERES_NO_UNORDERED_MAP
 #endif  // CERES_INTERNAL_COLLECTIONS_PORT_H_