Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-04-08 07:14:29


"Vladimir Prus" <ghost_at_[hidden]> wrote in message
news:200404081532.06583.ghost_at_cs.msu.su...

> > So you would like something like
> >
> > Email e = insert_with< &Email::add_cc >( e )( ... );
> >
> > ? Or perhaps
> >
> > Email e = insert_with( bind( e, &Email::add_cc ) )(...);
>
> Right. Though for implementing 'add_to' method inside 'Email' class it
will be
> necessary make insert_assigner have template parameter for a functor type.
> For example:
>
> insert_assigner_with_functor< function< void (string) > >
> add_cc(const string& s)
> {
> insert_assigner_with_functor< function< void(string> > > r(
> bind(this, &Email::add_cc));
>
> r(s);
> return r;
> }

This is something you could use in your program options, right?
I'll have to think more about it, but wouldn't this work:

insert_assigner< Email >
add_cc( const string& s )
{
    return insert< Email::add_cc >( *this )( s );
}

(given averything I haven't thought about works :-))

> In fact,
>
> using assignment::operator<<
>
> does not have this problem, though it's cumbersome.

it had with my compilers.

> > > I'd suggest the declare the operators outside of class declaration.
This
> >
> > will
> >
> > > give the compiler more freedom -- e.g. inlining only if maximum
> >
> > optimization
> >
> > > level is requested.
> >
> > I did not know there was a difference. Could you point to the place in
the
> > standard, please
> > (in particular, I couldn't find anything in 8.3.5 and 9.5 that supports
> > it).
>
> 9.3/2 says:
>
> A member function may be defined in its class definition, in which case
it
> is an inline member function.
>
> So defining a function inside class has the same effect as "inline"
specifier.

true, but the compiler is not forced to inline it. So unless you are talking
about
requiring linking, I don't get it.

> > > 3. I did not really understoon 'tuple_insert_assigner' role. Why is it
> >
> > needed?
> >
> > Basically because it does not call any constructor, but simply forwards
a
> > tuple of arguments
> > to your callback function. (It could be explained better). This is how I
> > call add_edge() in BGL
> > even though add_edge() takes 3 and 4 arguments.
>
> Ok, let me try from a different perspective: when instances of this class
are
> created? At least the documentation does not say they are created
anywhere...

I agree it is not explained; when you call insert() for adjacency_list it
will return such an instance.

br

Thorsten


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