From 3ff2ed2b95efe52999c7dbb57f0c95eed49d4649 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Sun, 29 Dec 2013 04:16:52 +0000 Subject: [PATCH] I don't remember doing this, and I have no idea when it was, but hey, using namespace std in cpp files is a cool idea. --- src/mlpack/core/util/string_util.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mlpack/core/util/string_util.cpp b/src/mlpack/core/util/string_util.cpp index c04be53b16..b8a0618f81 100644 --- a/src/mlpack/core/util/string_util.cpp +++ b/src/mlpack/core/util/string_util.cpp @@ -7,10 +7,11 @@ using namespace mlpack; using namespace mlpack::util; +using namespace std; //! A utility function that replaces all all newlines with a number of spaces //! depending on the indentation level. -std::string mlpack::util::Indent(std::string input) +string mlpack::util::Indent(string input) { // Tab the first line. input.insert(0, 1, ' '); @@ -20,10 +21,11 @@ std::string mlpack::util::Indent(std::string input) std::string tabbedNewline("\n "); // Replace all newline characters with the precomputed character sequence. - size_t start_pos = 0; - while((start_pos = input.find("\n", start_pos)) != std::string::npos) { - input.replace(start_pos, 1, tabbedNewline); - start_pos += tabbedNewline.length(); + size_t startPos = 0; + while ((startPos = input.find("\n", startPos)) != string::npos) + { + input.replace(startPos, 1, tabbedNewline); + startPos += tabbedNewline.length(); } return input;