[mlpack-svn] r14043 - mlpack/trunk/src/mlpack/core/util
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Dec 21 13:43:24 EST 2012
Author: rcurtin
Date: 2012-12-21 13:43:23 -0500 (Fri, 21 Dec 2012)
New Revision: 14043
Modified:
mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp
mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp
Log:
Do not make copies of objects when printing to output.
Modified: mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp 2012-12-21 18:13:08 UTC (rev 14042)
+++ mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp 2012-12-21 18:43:23 UTC (rev 14043)
@@ -107,7 +107,7 @@
//! Write anything else to the stream.
template<typename T>
- PrefixedOutStream& operator<<(T s);
+ PrefixedOutStream& operator<<(const T& s);
//! The output stream that all data is to be sent too; example: std::cout.
std::ostream& destination;
@@ -120,14 +120,14 @@
//! This handles forwarding all primitive types transparently
template<typename T>
- void CallBaseLogic(T s,
+ void CallBaseLogic(const T& s,
typename boost::disable_if<
boost::is_class<T>
>::type*);
//! Forward all objects that do not implement a ToString() method
template<typename T>
- void CallBaseLogic(T s,
+ void CallBaseLogic(const T& s,
typename boost::enable_if<
boost::is_class<T>
>::type*,
@@ -137,7 +137,7 @@
//! Call ToString() on all objects that implement ToString() before forwarding
template<typename T>
- void CallBaseLogic(T s,
+ void CallBaseLogic(const T& s,
typename boost::enable_if<
boost::is_class<T>
>::type*,
@@ -153,7 +153,7 @@
* @param val The The data to be output.
*/
template<typename T>
- void BaseLogic(T val);
+ void BaseLogic(const T& val);
/**
* Output the prefix, but only if we need to and if we are allowed to.
Modified: mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp 2012-12-21 18:13:08 UTC (rev 14042)
+++ mlpack/trunk/src/mlpack/core/util/prefixedoutstream_impl.hpp 2012-12-21 18:43:23 UTC (rev 14043)
@@ -16,7 +16,7 @@
namespace util {
template<typename T>
-PrefixedOutStream& PrefixedOutStream::operator<<(T s)
+PrefixedOutStream& PrefixedOutStream::operator<<(const T& s)
{
CallBaseLogic<T>(s);
return *this;
@@ -24,7 +24,7 @@
//! This handles forwarding all primitive types transparently
template<typename T>
-void PrefixedOutStream::CallBaseLogic(T s,
+void PrefixedOutStream::CallBaseLogic(const T& s,
typename boost::disable_if<
boost::is_class<T>
>::type* = 0)
@@ -34,7 +34,7 @@
// Forward all objects that do not implement a ToString() method transparently
template<typename T>
-void PrefixedOutStream::CallBaseLogic(T s,
+void PrefixedOutStream::CallBaseLogic(const T& s,
typename boost::enable_if<
boost::is_class<T>
>::type* = 0,
@@ -47,7 +47,7 @@
// Call ToString() on all objects that implement ToString() before forwarding
template<typename T>
-void PrefixedOutStream::CallBaseLogic(T s,
+void PrefixedOutStream::CallBaseLogic(const T& s,
typename boost::enable_if<
boost::is_class<T>
>::type* = 0,
@@ -60,7 +60,7 @@
}
template<typename T>
-void PrefixedOutStream::BaseLogic(T val)
+void PrefixedOutStream::BaseLogic(const T& val)
{
// 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).
More information about the mlpack-svn
mailing list