[mlpack-git] master: Remove special handling for ToString(). (a693c72)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Sun Dec 13 22:12:11 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/f535c29999c3d57b06664cceb871b5c937666586...21b198b20beae6e567dc8c1e47293ddde562bef2

>---------------------------------------------------------------

commit a693c72f904c316e04f16b3f52e4f0b1a3a553d6
Author: ryan <ryan at ratml.org>
Date:   Tue Dec 1 18:09:05 2015 -0500

    Remove special handling for ToString().


>---------------------------------------------------------------

a693c72f904c316e04f16b3f52e4f0b1a3a553d6
 src/mlpack/core.hpp                             |  1 -
 src/mlpack/core/util/CMakeLists.txt             |  1 -
 src/mlpack/core/util/ostream_extra.hpp          | 37 -----------------------
 src/mlpack/core/util/prefixedoutstream.hpp      | 30 -------------------
 src/mlpack/core/util/prefixedoutstream_impl.hpp | 39 +------------------------
 5 files changed, 1 insertion(+), 107 deletions(-)

diff --git a/src/mlpack/core.hpp b/src/mlpack/core.hpp
index dc9a8c2..c7076a2 100644
--- a/src/mlpack/core.hpp
+++ b/src/mlpack/core.hpp
@@ -159,7 +159,6 @@
 #include <mlpack/core/util/arma_traits.hpp>
 #include <mlpack/core/util/log.hpp>
 #include <mlpack/core/util/cli.hpp>
-#include <mlpack/core/util/ostream_extra.hpp>
 #include <mlpack/core/data/load.hpp>
 #include <mlpack/core/data/save.hpp>
 #include <mlpack/core/data/normalize_labels.hpp>
diff --git a/src/mlpack/core/util/CMakeLists.txt b/src/mlpack/core/util/CMakeLists.txt
index 67b549c..2db60eb 100644
--- a/src/mlpack/core/util/CMakeLists.txt
+++ b/src/mlpack/core/util/CMakeLists.txt
@@ -14,7 +14,6 @@ set(SOURCES
   option.hpp
   option.cpp
   option_impl.hpp
-  ostream_extra.hpp
   prefixedoutstream.hpp
   prefixedoutstream.cpp
   prefixedoutstream_impl.hpp
diff --git a/src/mlpack/core/util/ostream_extra.hpp b/src/mlpack/core/util/ostream_extra.hpp
deleted file mode 100644
index c96cb70..0000000
--- a/src/mlpack/core/util/ostream_extra.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file ostream_extra.hpp
- * @author Ryan Curtin
- *
- * Allow ostream::operator<<(T&) for mlpack objects that have ToString
- * implemented.
- */
-#ifndef __MLPACK_CORE_UTIL_OSTREAM_EXTRA_HPP
-#define __MLPACK_CORE_UTIL_OSTREAM_EXTRA_HPP
-
-#include "sfinae_utility.hpp"
-
-// Hide in a namespace so we don't pollute the global namespace.
-
-namespace mlpack {
-namespace util {
-namespace misc {
-
-HAS_MEM_FUNC(ToString, HasToString);
-
-} // namespace misc
-} // namespace util
-} // namespace mlpack
-
-template<
-    typename T,
-    typename junk1 = typename boost::enable_if<boost::is_class<T> >::type,
-    typename junk2 = typename boost::enable_if<
-        mlpack::util::misc::HasToString<T, std::string(T::*)() const> >::type
->
-std::ostream& operator<<(std::ostream& stream, const T& t)
-{
-  stream << t.ToString();
-  return stream;
-}
-
-#endif
diff --git a/src/mlpack/core/util/prefixedoutstream.hpp b/src/mlpack/core/util/prefixedoutstream.hpp
index 4f75759..7af4540 100644
--- a/src/mlpack/core/util/prefixedoutstream.hpp
+++ b/src/mlpack/core/util/prefixedoutstream.hpp
@@ -120,36 +120,6 @@ class PrefixedOutStream
   bool ignoreInput;
 
  private:
-  HAS_MEM_FUNC(ToString, HasToString)
-
-  //! This handles forwarding all primitive types transparently.
-  template<typename T>
-  void CallBaseLogic(const T& s,
-      typename boost::disable_if<
-          boost::is_class<T>
-      >::type* = 0);
-
-  //! Forward all objects that do not implement a ToString() method.
-  template<typename T>
-  void CallBaseLogic(const T& s,
-      typename boost::enable_if<
-          boost::is_class<T>
-      >::type* = 0,
-      typename boost::disable_if<
-          HasToString<T, std::string(T::*)() const>
-      >::type* = 0);
-
-  //! Call ToString() on all objects that implement ToString() before
-  //! forwarding.
-  template<typename T>
-  void CallBaseLogic(const T& s,
-      typename boost::enable_if<
-          boost::is_class<T>
-      >::type* = 0,
-      typename boost::enable_if<
-          HasToString<T, std::string(T::*)() const>
-      >::type* = 0);
-
   /**
    * Conducts the base logic required in all the operator << overloads.  Mostly
    * just a good idea to reduce copy-pasta.
diff --git a/src/mlpack/core/util/prefixedoutstream_impl.hpp b/src/mlpack/core/util/prefixedoutstream_impl.hpp
index dd7bc81..d86763f 100644
--- a/src/mlpack/core/util/prefixedoutstream_impl.hpp
+++ b/src/mlpack/core/util/prefixedoutstream_impl.hpp
@@ -18,45 +18,8 @@ namespace util {
 template<typename T>
 PrefixedOutStream& PrefixedOutStream::operator<<(const T& s)
 {
-  CallBaseLogic<T>(s);
-  return *this;
-}
-
-//! This handles forwarding all primitive types transparently.
-template<typename T>
-void PrefixedOutStream::CallBaseLogic(const T& s,
-    typename boost::disable_if<
-        boost::is_class<T>
-    >::type*)
-{
   BaseLogic<T>(s);
-}
-
-// Forward all objects that do not implement a ToString() method transparently.
-template<typename T>
-void PrefixedOutStream::CallBaseLogic(const T& s,
-    typename boost::enable_if<
-        boost::is_class<T>
-    >::type*,
-    typename boost::disable_if<
-        HasToString<T, std::string(T::*)() const>
-    >::type*)
-{
-  BaseLogic<T>(s);
-}
-
-// Call ToString() on all objects that implement ToString() before forwarding.
-template<typename T>
-void PrefixedOutStream::CallBaseLogic(const T& s,
-    typename boost::enable_if<
-        boost::is_class<T>
-    >::type*,
-    typename boost::enable_if<
-        HasToString<T, std::string(T::*)() const>
-    >::type*)
-{
-  std::string result = s.ToString();
-  BaseLogic<std::string>(result);
+  return *this;
 }
 
 template<typename T>



More information about the mlpack-git mailing list