Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Getting started

Boost , The Boost C++ Libraries BoostBook Documentation Subset , Chapter 38. Boost.TypeIndex 4.1

Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

boost::typeindex::type_info является заменой для std::type_info и boost::typeindex::type_index является заменой для std::type_index. В отличие от стандартных библиотечных версий, эти классы могут работать без RTTI.

type_index предоставляет полный набор операторов сравнения, функций хеширования и операторов потока, поэтому его можно использовать с любым классом контейнеров.

Чтобы начать использовать Boost. TypeIndex:

Заменить это:

Со следующим:

Больше информации

#include <typeinfo> #include <typeindex> 
#include <boost/type_indexhpp> 

more...

std::type_index<2 
boost::typeindex::type_index 

more...

typeid(T)typeid(T).name()//нечитаемый человекомtypeid(вариабельный
boost::type_id>()::typeindex::type_id::type_idtype_id 
typeindextype_id_runtime

more...

more...

more...

// попытаться сохранить const, volatile, reference typeid(please_save_modifiers<T>) 
//cvr = const, volatile, reference boost::typeindex::type_id_with_cvr<T>() 

more...

// когда требуется ссылка на  const type_info& v1  typeid; int; const type_info  typeidint; 
const boost::type_index:typeindextypeindex::type_id>();type_info::typeindextype_id>;

more...

more...

Если вы используете методы type_id_runtime() и RTTI отключен, убедитесь, что классы, которые передаются в type_id_runtime(), отмечены макро BOOST_TYPE_INDEX_REGISTER_CLASS.

Вот как можно использовать TypeIndex в boost/any.hpp:

Перед

С помощью TypeIndex

#include <typeinfo>
#include <boost/type_indexhpp>
виртуальный const type_info & type() const BOOST_NOEXCEPT  // требует RTTI typeid(ValueType);  
virtual consttypeindextype_info&BOOST_NOEXCEPT//теперь работает даже с отключенным RTTIreturn::typeindextype_id>();type_info

Вот как можно использовать 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;

PrevUpHomeNext

Статья Getting started раздела The Boost C++ Libraries BoostBook Documentation Subset Chapter 38. Boost.TypeIndex 4.1 может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: Chapter 38. Boost.TypeIndex 4.1 ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-19 17:35:44/0.026779174804688/1