mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Use std::any
when compiler supports C++17 or later
This commit is contained in:
parent
cbad214cdd
commit
8dfe07b5b5
@ -326,13 +326,13 @@ string const sanitizeLatexOption(string const & input)
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename Factory, typename Data, typename Transformer>
|
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)
|
Data const & data, Transformer & transformer)
|
||||||
{
|
{
|
||||||
if (any_factory.type() != typeid(Factory))
|
if (any_factory.type() != typeid(Factory))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Factory factory = boost::any_cast<Factory>(any_factory);
|
Factory factory = any_cast<Factory>(any_factory);
|
||||||
if (factory)
|
if (factory)
|
||||||
transformer = factory(data);
|
transformer = factory(data);
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
|
|
||||||
#include "graphics/GraphicsParams.h"
|
#include "graphics/GraphicsParams.h"
|
||||||
|
|
||||||
|
#include "support/any.h"
|
||||||
#include "support/Length.h"
|
#include "support/Length.h"
|
||||||
#include "support/unique_ptr.h"
|
#include "support/unique_ptr.h"
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -339,7 +338,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
template <typename Factory>
|
template <typename Factory>
|
||||||
TransformStore(TransformID id_, Factory const & 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 TransformCommand::ptr_type ComPtr;
|
||||||
typedef TransformOption::ptr_type OptPtr;
|
typedef TransformOption::ptr_type OptPtr;
|
||||||
@ -353,7 +352,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TransformID id;
|
TransformID id;
|
||||||
boost::any any_factory;
|
any any_factory;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace external
|
} // namespace external
|
||||||
|
@ -35,6 +35,7 @@ liblyxsupport_a_SOURCES = \
|
|||||||
FileMonitor.h \
|
FileMonitor.h \
|
||||||
FileMonitor.cpp \
|
FileMonitor.cpp \
|
||||||
RandomAccessList.h \
|
RandomAccessList.h \
|
||||||
|
any.h \
|
||||||
bind.h \
|
bind.h \
|
||||||
Cache.h \
|
Cache.h \
|
||||||
Changer.h \
|
Changer.h \
|
||||||
|
23
src/support/any.h
Normal file
23
src/support/any.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user