Boost logo

Boost Users :

Subject: Re: [Boost-users] Flyweight: wrapping shared_ptr
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2014-10-08 10:29:44


Akim Demaille <akim <at> lrde.epita.fr> writes:

>
> Le 8 oct. 2014 à 15:41, Joaquin M Lopez Munoz <joaquin <at> tid.es> a écrit :
>
> > Joaquin M Lopez Munoz <joaquin <at> tid.es> writes:
> >
> >> With pointer-like semantics, you have
> >>
> >> flyweight<foo> f;
> >> flyweight<foo*> g;
> >>
> >> f->x=0; // OK
> >> g->x=0; // error
> >
> > [...]
> >
> > std::cout<<f->x;
> > std::cout<<g->x;
> >
> > for instance. You get the idea, anyway.
>
> Yes, I think this time I see what you mean. You're proposing
>
> boost::flyweight<std::string> s("foo");
> std::cerr << s->size() << std::endl;
>
> to make sense, right?

Correct. Pointer semantics and pass-thru semantics cannot coexist in the
same interface (not that I'm currently considering supporting either,
anyway). For your case this is not a problemm, since you'll be using
some incarnation of your custom poly_flyweight, which you can endow with
whatever -> semantics you like (pass-thru, I presume).

Joaquín M López Muñoz
Telefónica


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net