Boost logo

Boost :

Subject: Re: [boost] [iostreams][io_state_savers] Request for interest in some ios_base basic utilities
From: Artyom Beilis (artyomtnk_at_[hidden])
Date: 2011-11-10 03:02:35


Hello! Actually such utilities are and would be very useful. The stateful manipulator is rather something simple however the second part the "state saver" is something very important. In fact today Boost.DateTime uses for example locale facet to provide such information which is wrong by design. If such state saver was around when it created it would be much better. So my +1 and big one. Few points. ------------ I had already implemented state saver for Boost.Locale but it is hidden in the sources, it has a little bit different approach but in general it is very similar. https://svn.boost.org/svn/boost/trunk/libs/locale/src/shared/ios_prop.hpp I'd also suggest to add std::ios_base::imbue_event handing because it may be actually important. (Consider some caching withing object) Now some important (extremely important) notes about this code: ---------------------------------------------------------------       static inline int index()       {         static const int v_ = std::ios_base::xalloc();         return v_;       } 1.  This code may be not thread safe and may create two different values for two different threads.     So I'd suggest to provide some global initialization option to at least illeminate somehow     this problem or to use Boost.Thread's ones initialization. 2.  This code can't be used on cross dll boundaries.     Consider you have function (non-linline) boost::foo::bar in libboost_foo.dll that updates manipulator     in the exe other inline function boost::foo::baz uses it.     You'll be surprised what will happen: the "static const int v_" in the index() function     would have two instances and would allocate two distinct indexes. 3.  You should never use it with static linked runtime and dlls (of course) because there will be     two instances of xalloc()'s counter.     But this is related to gcc 4.4 and below on Windows only. So library should be very careful and not use such smart pointer in inline instances and this should be written with big red letters in the top of the library docs. That is why Boost.Locale's ios_prop.hpp is hidden in sources. (Yep... dll platforms sucks... :-) or make our work a way much harder) Artyom Beilis -------------- CppCMS - C++ Web Framework:   http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ >________________________________ >From: Vicente J. Botet Escriba <vicente.botet_at_[hidden]> > > >Hi, > >I'm a beginner of the standard IOStream library. While restructuring Boost.Chrono I/O I have find some classes that could be of general use (if the design is correct, of course). > >The first one is quite simple, is used to define manipulators with parameters. Instead of defining a class and the correspondent stream inserters and extractors the manip template class do all this at once. > > [snip] > >Do you see a design flag on these classes? >If not, do you think these kind of utilities could be added to boost? >If yes, could these be merged with Boost.io_state_savers or Boost.IOStreams to form a larger io utilities libraries? > >Best, >Vicente > > > > >_______________________________________________ >Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost > >   


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk