Angus Leeming wrote: > Angus Leeming wrote: >> Lars Gullik Bjønnes wrote: >>> note the member function boost::any:type >> >> Bingo! No need for exceptions after all. >> Many thanks, Lars. > > Next iteration. I think that this is ready to convert into InsetExternal > code.
Hmmppfff! trying to do so, I get this ../../../boost/boost/any.hpp: In function `ValueType boost::any_cast(const boost::any&) [with ValueType = lyx::external::RotationCommandFactory]': ../../../src/insets/ExternalTemplate.h:54: instantiated from `void lyx::external::TransformStore::getTransformer(const Data&, Transformer&) const [with Factory = lyx::external::RotationCommandFactory, Data = lyx::external::RotationData, Transformer = std::auto_ptr<const lyx::external::TransformCommand>]' ../../../src/insets/insetexternal.C:790: instantiated from here ../../../boost/boost/any.hpp:174: exception handling disabled, use -fexceptions to enable template<typename ValueType> ValueType any_cast(const any & operand) { const ValueType * result = any_cast<ValueType>(&operand); if(!result) throw bad_any_cast(); return *result; } Could I insert BOOST_ASSERT(result); in its place please? The code is safe: if (any_factory.type() != typeid(Factory) || any_data.type() != typeid(Data)) return; Factory * factory = boost::any_cast<Factory>(any_factory); if (!factory.empty()) transformer = factory(data); -- Angus