multi_index uses serialization?

Hi, I have a simple question. Isn't there a way to create multi_indices without using the serialization library? I don't intend to stream them! thanks, Javier Gonzalez

Hello Javier,
----- Mensaje original -----
De: Javier Gonzalez
Hi,
I have a simple question. Isn't there a way to create multi_indices without using the serialization library? I don't intend to stream them!
If you don't use the serialization capabilities of multi_index_containers you won't need to link any Boost.Serialization module. So in your case you probably can use Boost.MultiIndex without having to consider Boost.Serialization at all. Furthermore, if for whatever reason you don't even want for Boost.MultiIndex to include any Boost.Serialization-related header (for instance, if you're using a partial copy of the Boost distro without the serialization stuff), this can be done by defining the macro BOOST_MULTI_INDEX_DISABLE_SERIALIZATION either globally (in your project settings or compiler commandline) or in each relevant .cpp prior to the inclusion of Boost.MultiIndex headers. Is this what you were after? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

That is exactly what I need. I will try it out. Thanks! Javier JOAQUIN LOPEZ MU?Z wrote:
Hello Javier,
----- Mensaje original ----- De: Javier Gonzalez
Fecha: Lunes, Febrero 26, 2007 9:49 pm Asunto: [Boost-users] multi_index uses serialization? Para: boost-users@lists.boost.org Hi,
I have a simple question. Isn't there a way to create multi_indices without using the serialization library? I don't intend to stream them!
If you don't use the serialization capabilities of multi_index_containers you won't need to link any Boost.Serialization module. So in your case you probably can use Boost.MultiIndex without having to consider Boost.Serialization at all.
Furthermore, if for whatever reason you don't even want for Boost.MultiIndex to include any Boost.Serialization-related header (for instance, if you're using a partial copy of the Boost distro without the serialization stuff), this can be done by defining the macro
BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
either globally (in your project settings or compiler commandline) or in each relevant .cpp prior to the inclusion of Boost.MultiIndex headers.
Is this what you were after?
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

I never realized this before. Truth is I never really looked at multi-index because I haven't needed it yet. But this post raises some questions in my mind. This means that the default is that any usage of multi-index includes serialization library headers regardless of whether boost serialization is to be used. This seems to me awkward for those that want to minimize dependencies, compile times, etc. It seems that it would also confuse things if one wanted to use a different serialization system other than the Boost one. When doing the serialization of std:: collections, I made headers of the form boost/serializaton/vector.hpp, etc. If course I couldn't mess with the headers std::vector.hpp, boost::shared_ptr, etc. But it seemed most natural to me as it only required code to be included that the programmer had made a deliberate decision to use. Given this I sort of expected to see boost/multi-index:/serialization/hashed_index.hpp or maybe boost/serialization/multi-index/hashed_index.hpp. These of course would include boost/multi-index/hashed_index.hpp etc as needed. I'm not campaigning for any change. Its just that I thing my way of doing it is better. This seems related to a short discussion that occurred some time ago regarding the appeal of "convenience headers" which make sure that everything one might need is included under the short name. Some people hate 'em (e.g. me) and some people love 'em. I also think that as boost grows, the disadvantages of "including every thing that might be useful" will be more apparent. Robert Ramey "JOAQUIN LOPEZ MU?Z" wrote:
Furthermore, if for whatever reason you don't even want for Boost.MultiIndex to include any Boost.Serialization-related header (for instance, if you're using a partial copy of the Boost distro without the serialization stuff), this can be done by defining the macro
BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
either globally (in your project settings or compiler commandline) or in each relevant .cpp prior to the inclusion of Boost.MultiIndex headers.

Robert Ramey wrote:
I never realized this before. Truth is I never really looked at multi-index because I haven't needed it yet. But this post raises some questions in my mind.
This means that the default is that any usage of multi-index includes serialization library headers regardless of whether boost serialization is to be used.
I agree this isn't optimal. I also don't think it's consistent with what other libraries do -- well at least date-time. So, date-time has added a 'convenience header' in 1.34 (boost/date_time.hpp) which includes all the types and the i/o, but not the serialization interfaces. You still have to specially include other headers to get the serialization functions. I'm not suggesting that this is the 'one right way', but I think it's a reasonable way.
...snip...
"JOAQUIN LOPEZ MU?Z" wrote:
Furthermore, if for whatever reason you don't even want for Boost.MultiIndex to include any Boost.Serialization-related header (for instance, if you're using a partial copy of the Boost distro without the serialization stuff), this can be done by defining the macro
BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
either globally (in your project settings or compiler commandline) or in each relevant .cpp prior to the inclusion of Boost.MultiIndex headers.
At a minimum this seems backwards in that I'll bet most MI users don't use serialization. I also don't really care for the macro approach -- probably because I have to clutter my code to turn something off. I'd usually expect to 'add something' to my code to enable another feature. Bust, I guess you could argue it either way. In any case it would be nice to be consistent across boost libs on this. What do the other libs that support serialization do -- what are they, graph, ? Jeff

Hello Robert, Robert Ramey ha escrito:
I never realized this before. Truth is I never really looked at multi-index because I haven't needed it yet. But this post raises some questions in my mind.
This means that the default is that any usage of multi-index includes serialization library headers regardless of whether boost serialization is to be used. This seems to me awkward for those that want to minimize dependencies, compile times, etc. It seems that it would also confuse things if one wanted to use a different serialization system other than the Boost one. When doing the serialization of std:: collections, I made headers of the form boost/serializaton/vector.hpp, etc. If course I couldn't mess with the headers std::vector.hpp, boost::shared_ptr, etc. But it seemed most natural to me as it only required code to be included that the programmer had made a deliberate decision to use. Given this I sort of expected to see boost/multi-index:/serialization/hashed_index.hpp or maybe boost/serialization/multi-index/hashed_index.hpp. These of course would include boost/multi-index/hashed_index.hpp etc as needed.
I'm not campaigning for any change. Its just that I thing my way of doing it is better.
Well, I thought about this kind of problems when designing the serialization support of B.MI, and what you've got is the best I came up with. There is a rationale for not having boost/multi_index/serialization/*_index.hpp headers, let me explain: When you serialize a multi_index_container comprised of N indices, every index gets involved in the serialization process; so, if you have something like: tyepedef multi_index_container< element, indexed_by< ordered_unique<...>, hashed_non_unique<...>, sequenced<...> >
mic_t;
and want to serialize objects of type mic_t, you'd have (according to the
serialization header model) to include the following:
#include
This seems related to a short discussion that occurred some time ago regarding the appeal of "convenience headers" which make sure that everything one might need is included under the short name. Some people hate 'em (e.g. me) and some people love 'em.
I also think that as boost grows, the disadvantages of "including every thing that might be useful" will be more apparent.
Of course, if someone comes up with a friendlier approach to this particular problem, I'd be happy to give it a try. Given the situation I described above, I don't see how to provide a more convenient header-based approach. Ideas? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín Mª López Muñoz wrote:
Hello Robert,
and want to serialize objects of type mic_t, you'd have (according to the serialization header model) to include the following:
#include
#include #include #include
I would have had each more specialized one include the common one
so it would look like
#include
Which looks like excessively cumbersome to me.
And that's where we differ. The above seems totally natural to me. It goes with my normal expectation that to get more features, I have to add more "stuff" so that I know that my program is using - and only using - what I think it is.
Failing to include one of the headers won't result in less-capable serialization support, only in a compile-time error when trying to stream mic_t's.
Agreed - Its not a huge issue for me. I would say its more of a strong personal preference. Robert Ramey
participants (5)
-
"JOAQUIN LOPEZ MU?Z"
-
Javier Gonzalez
-
Jeff Garland
-
Joaquín Mª López Muñoz
-
Robert Ramey