Robert Ramey | 1 Apr 2007 02:37

Re: [serialization] free load/save

Ruediger Berlich wrote:
> Dear all,
>
> I'd like to serialize a number of classes using the free-standing
> version of the serialize function. As I do not want to access
> internals of the classes directly, I have to work with set/get
> functions, which in turn implies having to write load/save functions.
>
> This seems to work for simple types, like in the following example.
> But will it circumvent any internal mechanisms of Boost.Serialization
> , if I do not give the library direct access to class data ? Will
> this work for complex types, e.g. vectors of shared_ptr objects ?

yes

The only problem will be with "secret" objects which are pointed to.

When you de-serialize them to the stack, the internal address is wrong
so after moving them using "get" you'll have to use "reset_object_address"
if they are trackable.

Robert Ramey

>
> /*************************************************************************/
>
> class base{
> public:
>    base(void){
>        setSecret(1);
(Continue reading)

Ruediger Berlich | 1 Apr 2007 02:47
Picon

Re: [serialization] free load/save

Robert,
thanks again for the quick and comprehensive reply !
Ruediger

Robert Ramey wrote:
> yes
> 
> The only problem will be with "secret" objects which are pointed to.
> 
> When you de-serialize them to the stack, the internal address is wrong
> so after moving them using "get" you'll have to use "reset_object_address"
> if they are trackable.
> 
> Robert Ramey
David Abrahams | 1 Apr 2007 03:27
Picon
Picon
Favicon
Gravatar

Re: Building for cygwin on Windows?


on Sat Mar 31 2007, "John Harper" <john-a-harper-AT-hotmail.com> wrote:

> I can't get the boost libraries to build correctly using Cygwin and GCC on 
> Windows XP. Boost seems determined to build for some kind of native Windows 
> environment. I'm trying:
>
> bjam "-sTOOLS=gcc" "--prefix=/usr/local"
>
> and it complains "wide i/o not supported on this platform". If I omit 
> --prefix it puts the libraries in the Windows file system under C:\Boost, 
> but even if I copy them to somewhere under cygwin and point GCC at them, it 
> still doesn't find them.
>
> SUrely I'm not the first person to want to do this? What is the magic 
> formula?

Are you using a windows build of bjam or a cygwin build?  You'll need
the latter.

--

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Don't Miss BoostCon 2007! ==> http://www.boostcon.com
Digvijoy Chatterjee | 1 Apr 2007 07:02
Picon

[lexical-cast] double not converted as it is to a string

Hello,
I am seeing this behavious with boost::lexical_cast<std::string>(double)
occasionaly numbers like 76.32 are being converted to strings of the
form 76.319999999
The expected behavior is seen for almost all doubles except for a few
which are reproducible
e.g. 76.32..

here is a simple program,
int main() {
double  d=76.32;
std::string s = boost::lexical_cast<std::string>(d);
cout << s << endl;
}

output
76.319999999...

a) am i doing something wrong ??
b) if this is not wrong s this standard behavior ??

Thanks
Digz
Tom Bachmann | 1 Apr 2007 11:03
Picon

Re: [lexical-cast] double not converted as it is to a string


Digvijoy Chatterjee schrieb:
> ...
> here is a simple program,
> int main() {
> double  d=76.32;
> std::string s = boost::lexical_cast<std::string>(d);
> cout << s << endl;
> }
> 
> output
> 76.319999999...
> 
> a) am i doing something wrong ??

I don't think so.

> b) if this is not wrong s this standard behavior ??
> 

I'd say so. Due to the binary representation not all numbers with a
representation of a fixed amount of digits in our decimal system have
such a representation in the computer. Lexical_cast internally uses
standard streams, if they don't correct such things (and I don't know of
any implemementation that'd do so), your output will look garbaged. Try
adding std::cout << d << std::endl.
--
-ness-
Digvijoy Chatterjee | 1 Apr 2007 16:23
Picon

Re: [lexical-cast] double not converted as it is to a string

> Digvijoy Chatterjee schrieb:
> > ...
> > here is a simple program,
> > int main() {
> > double  d=76.32;
> > std::string s = boost::lexical_cast<std::string>(d);
> > cout << s << endl;
> > }
> >
> > output
> > 76.319999999...
> >
> > a) am i doing something wrong ??
>
> I don't think so.
>
> > b) if this is not wrong s this standard behavior ??
> >
>
> I'd say so. Due to the binary representation not all numbers with a
> representation of a fixed amount of digits in our decimal system have
> such a representation in the computer. Lexical_cast internally uses
> standard streams, if they don't correct such things (and I don't know of
> any implemementation that'd do so), your output will look garbaged. Try
> adding std::cout << d << std::endl.

adding std::cout << d << std::endl; does prints it out correctly,  it
calls setprecision with a default value of 6 which does rounding ,
I assume there is no way to play with setprecision and lexical_cast ,
or to a more general problem of rounding doubles to certain places of
(Continue reading)

Ben Artin | 1 Apr 2007 11:28

Re: [lexical-cast] double not converted as it is to a string

In article <2f7228250703312202y4cce5ac0o870fe26b59acfa7e <at> mail.gmail.com>,
 "Digvijoy Chatterjee" <digvijoy.c <at> gmail.com> wrote:

> I am seeing this behavious with boost::lexical_cast<std::string>(double)
> occasionaly numbers like 76.32 are being converted to strings of the
> form 76.319999999

<http://www.lahey.com/float.htm>

--

-- 
I changed my name: <http://periodic-kingdom.org/People/NameChange.php>
Christian Henning | 1 Apr 2007 19:48
Picon

[mpl] find_all type vectors in a type matrix that match a predicate.

Hi there,

is it possible to find all type vectors in a type matrix ( 2D type
vector ) that match a predicate? In the end I would like to have them
in another type matrix.

Can somebody point out how I would put together such a metafunction?
I'm not sure if the mpl lib supports my feature request.

Consider the following code:

#include "boost/mpl/vector.hpp"
#include <boost/mpl/find_if.hpp>
#include <boost/mpl/at.hpp>

using namespace std;
using namespace boost;

namespace fields
{
  struct id {};
  struct name {};
  struct address {};
  struct birthday {};
}

namespace tags
{
  struct primary {};
  struct foreign {};
(Continue reading)

David Abrahams | 1 Apr 2007 21:04
Picon
Picon
Favicon
Gravatar

Re: [mpl] find_all type vectors in a type matrix that match a predicate.


on Sun Apr 01 2007, "Christian Henning" <chhenning-AT-gmail.com> wrote:

> Hi there,
>
> is it possible to find all type vectors in a type matrix ( 2D type
> vector ) that match a predicate? In the end I would like to have them
> in another type matrix.

How about using filter_view?

> Can somebody point out how I would put together such a metafunction?
> I'm not sure if the mpl lib supports my feature request.
>
> Consider the following code:
>
> #include "boost/mpl/vector.hpp"
> #include <boost/mpl/find_if.hpp>
> #include <boost/mpl/at.hpp>
>
> using namespace std;
> using namespace boost;
>
> namespace fields
> {
>   struct id {};
>   struct name {};
>   struct address {};
>   struct birthday {};
> }
(Continue reading)

Ruediger Berlich | 1 Apr 2007 20:39
Picon

[serialization] abstract templatized base class

Hi again,

apologies for the frequent questions. Here is another problem I've
run into. I think I've found a solution, but would like to cross-check
whether I'm right.

I have a number of templatized base classes, that contain purely virtual
member functions. As per the Boost.Serialization documentation, purely
virtual classes should be labelled as "abstract".

>From the documentation and the header file "is_abstract.hpp" it appears as
if using the macro BOOST_IS_ABSTRACT would not work (indeed it produces
lots of error messages) for templatized classes, but that I should instead
add the following to the header:

namespace boost {
namespace serialization {
template<class T>
struct is_abstract<myClass<T> > {
    typedef mpl::bool_<true> type;
    BOOST_STATIC_CONSTANT(bool, value = true);
};
}}

Indeed this seems to work. 

It appears to me as if another solution might be to use the original macro
in those files where the templatized classes are first instantiated
(i.e. "filled" with a type). Please note, though, that they are
base-classes for some other non-abstract classes, so that I'm not sure this
(Continue reading)


Gmane