![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
Getting startedBoost , The Boost C++ Libraries BoostBook Documentation Subset , Chapter 38. Boost.TypeIndex 4.1
|
Заменить это: |
Со следующим: |
Больше информации |
---|---|---|
#include <typeinfo> #include <typeindex> |
#include <boost/type_indexhpp> |
|
std::type_index<2 |
boost::typeindex::type_index |
|
typeid(T)typeid(T).name()//нечитаемый человекомtypeid(вариабельный |
boost::type_id>()::typeindex::type_id::type_idtype_idtypeindextype_id_runtime |
more... |
// попытаться сохранить const, volatile, reference typeid(please_save_modifiers<T>) |
//cvr = const, volatile, reference boost::typeindex::type_id_with_cvr<T>() |
|
// когда требуется ссылка на const type_info& v1 typeid; int; const type_info typeidint; |
const boost::type_index:typeindextypeindex::type_id>();type_info::typeindextype_id>; |
Если вы используете методы type_id_runtime()
и RTTI отключен, убедитесь, что классы, которые передаются в type_id_runtime()
, отмечены макро BOOST_TYPE_INDEX_REGISTER_CLASS
.
Вот как можно использовать TypeIndex в boost/any.hpp
:
Вот как можно использовать TypeIndex в boost/вариант/вариант.hpp
:
Перед |
С помощью TypeIndex |
---|---|
#if !defined(BOOST_NO_TYPEID>#include <typeinfo> // для typeid, std::type_info #endif //BOOST_NO_TYPEID |
#include <boost/type_indexhpp> |
#if!reflectreflectpublicconststdpublic:2>templatetypename:2>операторconstconstconsttypeid>>endif> //BOOST_NO_TYPEID |
class reflect publictypeindextypeindex:2>typename :2>>boosttypeindexоператорT&констTtypeindex:5>::typeindextypeindextypeindextype_id>; |
#if!BOOST_NO_TYPEIDstd::type_info&::вариант::reflectreflect; return->visitor#endif |
const boost::type_info&:вариант::reflectreflect; return->apply_visitorvisitor; |
Статья Getting started раздела The Boost C++ Libraries BoostBook Documentation Subset Chapter 38. Boost.TypeIndex 4.1 может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
:: Главная :: Chapter 38. Boost.TypeIndex 4.1 ::
реклама |