[mlpack-svn] r13458 - in mlpack/trunk/src/mlpack/core: dists util
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Aug 27 10:09:00 EDT 2012
Author: trironk3
Date: 2012-08-27 10:09:00 -0400 (Mon, 27 Aug 2012)
New Revision: 13458
Modified:
mlpack/trunk/src/mlpack/core/dists/discrete_distribution.cpp
mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp
mlpack/trunk/src/mlpack/core/util/sfinae_utility.hpp
Log:
Added more documentation to sfinae_utility.hpp.
Modified: mlpack/trunk/src/mlpack/core/dists/discrete_distribution.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/dists/discrete_distribution.cpp 2012-08-27 03:49:30 UTC (rev 13457)
+++ mlpack/trunk/src/mlpack/core/dists/discrete_distribution.cpp 2012-08-27 14:09:00 UTC (rev 13458)
@@ -83,7 +83,7 @@
std::string DiscreteDistribution::ToString() const
{
std::ostringstream convert;
- convert << "Distribution" << this << std::endl;
+ convert << "DiscreteDistribution " << this << std::endl;
convert << probabilities;
return convert.str();
}
Modified: mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp 2012-08-27 03:49:30 UTC (rev 13457)
+++ mlpack/trunk/src/mlpack/core/util/prefixedoutstream.hpp 2012-08-27 14:09:00 UTC (rev 13458)
@@ -116,7 +116,7 @@
private:
HAS_MEM_FUNC(ToString, HasToString)
-
+
//! This handles forwarding all primitive types transparently
template<typename T>
void CallBaseLogic(T s,
Modified: mlpack/trunk/src/mlpack/core/util/sfinae_utility.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/sfinae_utility.hpp 2012-08-27 03:49:30 UTC (rev 13457)
+++ mlpack/trunk/src/mlpack/core/util/sfinae_utility.hpp 2012-08-27 14:09:00 UTC (rev 13458)
@@ -14,25 +14,33 @@
#include <boost/type_traits.hpp>
/*
- * Note: This macro is taken from http://stackoverflow.com/a/264088/391618
+ * Constructs a template supporting the SFINAE pattern.
*
* This macro generates a template struct that is useful for enabling/disabling
* a method if the template class passed in contains a member function matching
* a given signature with a specified name.
*
+ * The generated struct should be used in conjunction with boost::disable_if and
+ * boost::enable_if. Here is an example usage:
+ *
+ * For general references, see:
+ * http://stackoverflow.com/a/264088/391618
+ *
+ * For an MLPACK specific use case, see /mlpack/core/util/prefixedoutstream.hpp
+ * and /mlpack/core/util/prefixedoutstream_impl.hpp
+ *
* @param NAME the name of the struct to construct. For example: HasToString
* @param FUNC the name of the function to check for. For example: ToString
*/
#define HAS_MEM_FUNC(FUNC, NAME) \
- template<typename T, typename sig> \
- struct NAME { \
- typedef char yes; \
- typedef long no; \
- template <typename U, U> struct type_check; \
- template <typename _1> static yes &chk(type_check<sig, &_1::FUNC> *); \
- template <typename > static no &chk(...); \
- static bool const value = sizeof(chk<T>(0)) == sizeof(yes); \
- };
+template<typename T, typename sig> \
+struct NAME { \
+ typedef char yes; \
+ typedef long no; \
+ template <typename U, U> struct type_check; \
+ template <typename _1> static yes &chk(type_check<sig, &_1::FUNC> *); \
+ template <typename > static no &chk(...); \
+ static bool const value = sizeof(chk<T>(0)) == sizeof(yes); \
+};
-
#endif
More information about the mlpack-svn
mailing list