[mlpack-svn] r11453 - mlpack/trunk/src/mlpack/core/util
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Feb 9 19:10:41 EST 2012
Author: jcline3
Date: 2012-02-09 19:10:41 -0500 (Thu, 09 Feb 2012)
New Revision: 11453
Modified:
mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp
Log:
This fixes the arm test bug.
For whatever reason, boost::lexical_cast doesn't work right all of the time.
Thus, switch to stringstreams, since we are always converting *into* a string,
this should be fine for everything.
Modified: mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp 2012-02-10 00:07:50 UTC (rev 11452)
+++ mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp 2012-02-10 00:10:41 UTC (rev 11453)
@@ -10,6 +10,7 @@
// Just in case it hasn't been included.
#include "prefixedoutstream.hpp"
+#include <iostream>
template<typename T>
PrefixedOutStream& PrefixedOutStream::operator<<(T s)
@@ -25,14 +26,27 @@
// We will use this to track whether or not we need to terminate at the end of
// this call (only for streams which terminate after a newline).
bool newlined = false;
+ std::string line;
// If we need to, output the prefix.
PrefixIfNeeded();
- // Now we try to output the T (whatever it is).
- try
+ std::ostringstream convert;
+ convert << val;
+
+ if(convert.fail())
{
- std::string line = boost::lexical_cast<std::string>(val);
+ PrefixIfNeeded();
+ if (!ignoreInput)
+ {
+ destination << "Failed lexical_cast<std::string>(T) for output; output"
+ " not shown." << std::endl;
+ newlined = true;
+ }
+ }
+ else
+ {
+ line = convert.str();
// If the length of the casted thing was 0, it may have been a stream
// manipulator, so send it directly to the stream and don't ask questions.
@@ -74,17 +88,6 @@
destination << line.substr(pos);
}
}
- catch (boost::bad_lexical_cast &e)
- {
- // Warn the user that there was a failure.
- PrefixIfNeeded();
- if (!ignoreInput)
- {
- destination << "Failed lexical_cast<std::string>(T) for output; output"
- " not shown." << std::endl;
- newlined = true;
- }
- }
// If we displayed a newline and we need to terminate afterwards, do that.
if (fatal && newlined)
More information about the mlpack-svn
mailing list