[mlpack-git] master: Organizes boost backporting with core/boost_backport/boost_backport.hpp (d0f0c89)

gitdub at mlpack.org gitdub at mlpack.org
Thu Jul 21 09:35:25 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/ba850f782a53c5a77b7985f7647f609bd96cb5e7...2c026d838925df436d967439899813da5d34c702

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

commit d0f0c89bf6183a19950a99002292528f7d2589e5
Author: Yannis Mentekidis <mentekid at gmail.com>
Date:   Thu Jul 21 14:35:25 2016 +0100

    Organizes boost backporting with core/boost_backport/boost_backport.hpp


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

d0f0c89bf6183a19950a99002292528f7d2589e5
 src/mlpack/core/boost_backport/boost_backport.hpp | 41 +++++++++++++++++++++++
 src/mlpack/core/dists/gamma_distribution.cpp      |  2 +-
 src/mlpack/prereqs.hpp                            |  8 ++---
 3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/src/mlpack/core/boost_backport/boost_backport.hpp b/src/mlpack/core/boost_backport/boost_backport.hpp
new file mode 100644
index 0000000..7247fa4
--- /dev/null
+++ b/src/mlpack/core/boost_backport/boost_backport.hpp
@@ -0,0 +1,41 @@
+/**
+ * @file boost_backport.hpp
+ * @author Yannis Mentekidis
+ *
+ * Centralized control of what boost files to include. We have backported the
+ * following boost functionality:
+ *
+ *  * unordered_set serialization support (added in boost 1.56.0)
+ *  * trigamma and polygamma function evaluation (added in boost 1.58.0)
+ *
+ * If the detected boost version is greater than 1.58.0, we include the normal
+ * serialization, polygamma and trigamma functions (not the backported ones). 
+ * For versions 1.56, 1.57 we include the normal serialization but the 
+ * backported polygamma and trigamma functions.
+ * For all older versions we include the backported headers.
+ */
+
+#ifndef MLPACK_CORE_BOOST_BACKPORT_HPP
+#define MLPACK_CORE_BOOST_BACKPORT_HPP
+
+#if BOOST_VERSION < 105600
+  // Full backport.
+  #include "mlpack/core/boost_backport/unordered_map.hpp"
+  #include "mlpack/core/boost_backport/trigamma.hpp"
+  #include "mlpack/core/boost_backport/polygamma.hpp"
+
+#elif BOOST_VERSION < 105800
+  // Backport trigamma and polygamma.
+  #include <boost/serialization/unordered_map.hpp>
+  #include "mlpack/core/boost_backport/trigamma.hpp"
+  #include "mlpack/core/boost_backport/polygamma.hpp"
+
+#else
+  // Don't backport anything.
+  #include <boost/serialization/unordered_map.hpp>
+  #include <boost/math/special_functions/trigamma.hpp>
+  #include <boost/math/special_functions/polygamma.hpp>
+#endif
+
+#endif // MLPACK_CORE_BOOST_BACKPORT_HPP
+
diff --git a/src/mlpack/core/dists/gamma_distribution.cpp b/src/mlpack/core/dists/gamma_distribution.cpp
index 868fd32..c6790e0 100644
--- a/src/mlpack/core/dists/gamma_distribution.cpp
+++ b/src/mlpack/core/dists/gamma_distribution.cpp
@@ -7,7 +7,7 @@
 #include "gamma_distribution.hpp"
 
 #include <boost/math/special_functions/digamma.hpp>
-#include "mlpack/core/boost_backport/trigamma.hpp"
+#include "mlpack/core/boost_backport/boost_backport.hpp"
 
 using namespace mlpack;
 using namespace mlpack::distribution;
diff --git a/src/mlpack/prereqs.hpp b/src/mlpack/prereqs.hpp
index 4950282..a9d7fcb 100644
--- a/src/mlpack/prereqs.hpp
+++ b/src/mlpack/prereqs.hpp
@@ -55,11 +55,9 @@
 #include <boost/serialization/serialization.hpp>
 #include <boost/serialization/vector.hpp>
 #include <boost/serialization/map.hpp>
-#if BOOST_VERSION < 105500 // Old versions don't have unordered_map support.
-  #include "core/boost_backport/unordered_map.hpp"
-#else
-  #include <boost/serialization/unordered_map.hpp>
-#endif
+// boost_backport.hpp handles the version and backporting of serialization (and
+// other) features.
+#include "mlpack/core/boost_backport/boost_backport.hpp"
 // Boost 1.59 and newer don't use BOOST_PFTO, but our shims do.  We can resolve
 // any issue by setting BOOST_PFTO to nothing.
 #ifndef BOOST_PFTO




More information about the mlpack-git mailing list