Explicitly import string into the Ceres namespace. This is a workaround for anyone building Ceres in an environment where there is a non-standard string implementation in the global namespace. Due to the way the standard is written, a "using namespace X" import is not high enough precedence to resolve a naked reference to "string". Instead, by explicitly importing string, the lookup becomes unambiguous. Change-Id: I8d70463de01c482796c5bc09da05b37d21e7af96
diff --git a/include/ceres/internal/port.h b/include/ceres/internal/port.h index 9a3e5cc..a9fe247 100644 --- a/include/ceres/internal/port.h +++ b/include/ceres/internal/port.h
@@ -31,6 +31,8 @@ #ifndef CERES_PUBLIC_INTERNAL_PORT_H_ #define CERES_PUBLIC_INTERNAL_PORT_H_ +#include <string> + namespace ceres { // It is unfortunate that this import of the entire standard namespace is @@ -39,6 +41,10 @@ // things outside of the Ceres optimization package. using namespace std; +// This is necessary to properly handle the case that there is a different +// "string" implementation in the global namespace. +using std::string; + } // namespace ceres #endif // CERES_PUBLIC_INTERNAL_PORT_H_