Browse Source

Fix run_compile_commands build on Apple GCC 3.3

This compiler does not provide the "at" method of std::map.  Approximate
it well enough for our needs.
Brad King 14 years ago
parent
commit
a7e7a04aaf
1 changed files with 13 additions and 1 deletions
  1. 13 1
      Tests/CMakeLib/run_compile_commands.cxx

+ 13 - 1
Tests/CMakeLib/run_compile_commands.cxx

@@ -2,7 +2,19 @@
 
 class CompileCommandParser {
 public:
-  typedef std::map<std::string, std::string> CommandType;
+  class CommandType: public std::map<cmStdString, cmStdString>
+  {
+  public:
+#if defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4
+    cmStdString const& at(cmStdString const& k) const
+      {
+      const_iterator i = this->find(k);
+      if(i != this->end()) { return i->second; }
+      static cmStdString empty;
+      return empty;
+      }
+#endif
+  };
   typedef std::vector<CommandType> TranslationUnitsType;
 
   CompileCommandParser(std::ifstream *input)