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

Serialization - BOOST_STATIC_WARNING

Boost , ,

C++ Boost

Serialization

void_cast


Motivation

C++ includes the operator dynamic_cast<T>(U * u) for casting a pointer at runtime between two related types. However, this can only be used for polymorphic classes. That is, it can only be used with related classes which have at least one virtual function. Limiting the serializaton of pointers to only such classes would diminish the applicability of the library.

Usage

The following functions are defined in the header void_cast.hpp. They are declared in the namespace boost::serialization.


template<class Derived, class Base>
const void_cast_detail::void_caster &
void_cast_register(
    Derived const * derived = NULL, 
    Base * const base = NULL
);

This function "registers" a pair of related types. It stores the fact that Derived is immediately derived from Base in a global table.
  • This "registration" can be invoked anywhere in the program. The table is built at pre-runtime and is available anywhere else in the program.
  • only adjacent base/derived pairs need be registered. That is,
    
      void_cast_register<A, B>();
      void_cast_register<B, C>();
      
    automatically derives the fact that A can be upcast to C and vice-versa.


void *
void_upcast(
    extended_type_info const & derived_type,
    extended_type_info const & base_type,
    void * const t 
);


void *
void_downcast(
    extended_type_info const & derived_type,
    extended_type_info const & base_type,
    void * const t 
);

These functions cast a void pointer from one type to another. The source and definition types are specified by passing references to the corresponding extended_type_info records. An attempt to cast between types not "registered" with void_cast_register will throw a boost::archive::archive_exception with value equal to unregistered_cast

© Авторское правоРоберт Рэми2002-2004. Распространяется под лицензией Boost Software License, версия 1.0. (См. сопроводительный файл LICENSE_1_0.txt или копию по адресу http://www.boost.org/LICENSE_1_0.txt)

Статья Serialization - BOOST_STATIC_WARNING раздела может быть полезна для разработчиков на c++ и boost.




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



:: Главная :: ::


реклама


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

Время компиляции файла: 2024-08-30 11:47:00
2025-05-20 18:33:06/0.0026040077209473/0