commit 8dfe07b5b54e5ba4147545407cdc1f422e753861
Author: Yuriy Skalko <yuriy.ska...@gmail.com>
Date:   Sat Nov 21 16:27:13 2020 +0200

    Use `std::any` when compiler supports C++17 or later
---
 src/insets/ExternalTransforms.cpp |    4 ++--
 src/insets/ExternalTransforms.h   |    7 +++----
 src/support/Makefile.am           |    1 +
 src/support/any.h                 |   23 +++++++++++++++++++++++
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/insets/ExternalTransforms.cpp 
b/src/insets/ExternalTransforms.cpp
index 4f85f9d..9ff5772 100644
--- a/src/insets/ExternalTransforms.cpp
+++ b/src/insets/ExternalTransforms.cpp
@@ -326,13 +326,13 @@ string const sanitizeLatexOption(string const & input)
 namespace {
 
 template <typename Factory, typename Data, typename Transformer>
-void extractIt(boost::any const & any_factory,
+void extractIt(any const & any_factory,
               Data const & data, Transformer & transformer)
 {
        if (any_factory.type() != typeid(Factory))
                return;
 
-       Factory factory = boost::any_cast<Factory>(any_factory);
+       Factory factory = any_cast<Factory>(any_factory);
        if (factory)
                transformer = factory(data);
 }
diff --git a/src/insets/ExternalTransforms.h b/src/insets/ExternalTransforms.h
index 8b22f62..62e3342 100644
--- a/src/insets/ExternalTransforms.h
+++ b/src/insets/ExternalTransforms.h
@@ -14,11 +14,10 @@
 
 #include "graphics/GraphicsParams.h"
 
+#include "support/any.h"
 #include "support/Length.h"
 #include "support/unique_ptr.h"
 
-#include <boost/any.hpp>
-
 #include <functional>
 #include <map>
 #include <memory>
@@ -339,7 +338,7 @@ public:
         */
        template <typename Factory>
        TransformStore(TransformID id_, Factory const & factory)
-               : id(id_), any_factory(boost::any(factory)) {}
+               : id(id_), any_factory(any(factory)) {}
 
        typedef TransformCommand::ptr_type ComPtr;
        typedef TransformOption::ptr_type  OptPtr;
@@ -353,7 +352,7 @@ public:
 
 private:
        TransformID id;
-       boost::any any_factory;
+       any any_factory;
 };
 
 } // namespace external
diff --git a/src/support/Makefile.am b/src/support/Makefile.am
index 45d30b8..4ff8618 100644
--- a/src/support/Makefile.am
+++ b/src/support/Makefile.am
@@ -35,6 +35,7 @@ liblyxsupport_a_SOURCES = \
        FileMonitor.h \
        FileMonitor.cpp \
        RandomAccessList.h \
+       any.h \
        bind.h \
        Cache.h \
        Changer.h \
diff --git a/src/support/any.h b/src/support/any.h
new file mode 100644
index 0000000..e8f6a11
--- /dev/null
+++ b/src/support/any.h
@@ -0,0 +1,23 @@
+// -*- C++ -*-
+/**
+ * \file any.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Yuriy Skalko
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef LYX_ANY_H
+#define LYX_ANY_H
+
+#if __cplusplus >= 201703L
+       #include <any>
+       namespace lyx { using std::any; }
+#else
+       #include <boost/any.hpp>
+       namespace lyx { using boost::any; }
+#endif
+
+#endif // LYX_ANY_H
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to