[mlpack-git] master: Add a templated version for BOOST_CLASS_VERSION(). (ff7877d)

gitdub at mlpack.org gitdub at mlpack.org
Wed Jun 1 13:54:08 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/1f562a1aba7ae55475afcc95659511c2b7f694e5...5b8fdce471328f722fcd8c0f22a6d995ce22c98b

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

commit ff7877d28efd2e713c29de0f5934e14e485136fe
Author: Ryan Curtin <ryan at ratml.org>
Date:   Wed Jun 1 07:45:17 2016 -0700

    Add a templated version for BOOST_CLASS_VERSION().


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

ff7877d28efd2e713c29de0f5934e14e485136fe
 .../core/data/serialization_template_version.hpp   | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/mlpack/core/data/serialization_template_version.hpp b/src/mlpack/core/data/serialization_template_version.hpp
new file mode 100644
index 0000000..5d3f5b4
--- /dev/null
+++ b/src/mlpack/core/data/serialization_template_version.hpp
@@ -0,0 +1,38 @@
+/**
+ * @file serialization_template_version.hpp
+ * @author Ryan Curtin
+ *
+ * A better version of the BOOST_CLASS_VERSION() macro that supports templated
+ * classes.
+ */
+#ifndef MLPACK_CORE_DATA_SERIALIZATION_TEMPLATE_VERSION_HPP
+#define MLPACK_CORE_DATA_SERIALIZATION_TEMPLATE_VERSION_HPP
+
+/**
+ * Use this like BOOST_CLASS_VERSION(), but for templated classes.  The first
+ * argument is the signature for the template.  Here is an example for
+ * math::Range<eT>:
+ *
+ * BOOST_TEMPLATE_CLASS_VERSION(template<typename eT>, math::Range<eT>, 1);
+ */
+#define BOOST_TEMPLATE_CLASS_VERSION(SIGNATURE, T, N) \
+namespace boost { \
+namespace serialization { \
+template<> \
+SIGNATURE \
+struct version<T> \
+{ \
+  typedef mpl::int_<N> type; \
+  typedef mpl::integral_c_tag tag; \
+  BOOST_STATIC_CONSTANT(int, value = version::type::value); \
+  BOOST_MPL_ASSERT(( \
+      boost::mpl::less< \
+          boost::mpl::int_<N>, \
+          boost::mpl::int_<256> \
+      > \
+  )); \
+}; \
+} \
+}
+
+#endif




More information about the mlpack-git mailing list