|
Boost : |
From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-31 15:49:01
"David Abrahams" <dave_at_[hidden]> wrote:
> From: "Larry Evans" <jcampbell3_at_[hidden]>
>
>
> > David Abrahams wrote:
> >
>
> > >Isn't it time, finally, to stick the allocation inside a factory
> function
> > >for the outer shared pointer object so that the user never has to touch
> it?
[...]
> It's the "forwarding function" problem. The language as currently
specified
> would require users to use boost::ref() to pass non-const references, and
> would require the factory function implementation to use
> boost::unwrap_reference to get the reference out.
If I understand correctly, the number of parameters = n... not infinite
(although it would be great to name and forward the parameter '...' to
another function).
On the other hand (rc) could be renamed to (gc), opening some doors to real
garbage collectors related to specific FILE *, (* function)(), stack depth,
countdown, etc. Here is what the header could look like:
struct placed_ptr_header
{
int m_count;
enum {depth, timer, ...} m_type;
union
{
int m_depth;
int m_timer;
int m_signum;
pid_t m_pid;
FILE * m_file;
void (* m_function)(...);
};
static size_t const s_padding;
};
struct gc_type
{
gc_type & operator () (int)
{
...
}
...
} gc;
placed_ptr<T> p = new (gc) int;
placed_ptr<T> q = new (gc(fopen("fifo"))) monitor("daemon X");
I'm not a garbage collector expert, but it is just a _suggestion_ that could
be useful...
Philippe A. Bouchard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk