Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-04-12 04:37:27


Hi Vladimir,

"Vladimir Prus" <ghost_at_[hidden]> wrote in message
news:c5dcug$67c$1_at_sea.gmane.org...
> Thorsten Ottosen wrote:
>
> >> > won't boost::ref <> "solve" this. (don't bind use &?)
> >>
> >> No and no.
> >
> > (a)
> > My comments about boost::bind comes from
> > http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm
> >
> > But bind's reference docs seems to use by-value.
>
> Looking at the code, it seems boost::bind uses non-const reference for
> operator() -- the actual forwarding -- and by-value for arguments to
'bind'
> itself.

I must admit I don't get that. I extended rhe example to show the problems
(see attachment).
As you point out, bind() *silently* compiles code that would not compile if
one called the original function with those arguments. IMO, *very*
trouplesome. Could
the authors of bind/function please comment on why that has been allowed?

> So, you should add pass by non-const reference to the list of
alternatives.

yeah, that's one of the alternatives discussed in Howard and Dave's paper..

> What I think about it is that const-reference prevents you from passing
> non-const references to constructors of objects you put to container.

only in the sense that you need to use boost::ref<>

>OTOH,
> with non-const references you'd break the passing of integer literals --

any "literal", in fact.

> which is the point of the library.

yes.

> Maybe, you really should support ref<> for passing non-const references.

Depends on what you mean by support :-) It's already supported by using
ref<>. I think
that is ok; afterall, reference arguments should not be used that much
thoughout code.

br

Thorsten

begin 666 ref.cpp
M#0HC:6YC;'5D92 \8F]O<W0O<F5F+FAP<#X-"B-I;F-L=61E(#QI;W-T<F5A
M;3X-"B-I;F-L=61E(#QB;V]S="]B:6YD+FAP<#X-"@T*=7-I;F<@;F%M97-P
M86-E('-T9#L-"G5S:6YG(&YA;65S<&%C92!B;V]S=#L-"@T*=F]I9"!F;V\H
M(&EN="8@:2 I( T*>PT*(" @(&-O=70@/#P@)FD@/#P@(B B.PT*?0T*#0IT
M96UP;&%T93P_at_8VQA<W,@5" ^#0IV;VED(&9O<G=A<F0H(%0@=" I#0I[#0H@
M(" @9F]O*"!T("D[#0I]#0H-"G1E;7!L871E/"!C;&%S<R!4(#X-"G9O:60@
M<')O<&5R7V9O<G=A<F0H(&-O;G-T(%0F('0@*0T*>PT*(" @(&9O;R@@=" I
M.PT*?0T*#0II;G0@;6%I;B_at_I#0I[#0H@(" @:6YT(&D@/2 Q.PT*(" @(&-O
M;G-T(&EN="!C:2 ](#$[#0H@(" @8V]U=" \/" F:2 \/" B("([#0H@(" @
M9F]R=V%R9"@@:2 I.R @+R\@;V]P<PT*(" @(&9O<G=A<F0H(&D@*3L@("\O
M(&]O<',-"B @(" O+W!R;W!E<E]F;W)W87)D*"!I("D@+R\@=V]N)W0_at_8V]M
M<&EL90T*(" @('!R;W!E<E]F;W)W87)D*"!R968\:6YT/BAI*2 I.PT*(" @
M("\O<')O<&5R7V9O<G=A<F0H(&-R968\:6YT/BAI*2 I.R O+R!W;VXG="!C
M;VUP:6QE#0H@(" @8FEN9"@@9F]O+"!I("DH*3L@("\O(&]O<',-"B @("!B
M:6YD*"!F;V\L(&-I("DH*3L@+R\@;V]P<PT*(" @(&)I;F0H(&9O;RP@<F5F
8/&EN=#XH:2D@*2_at_I.R O+R!O:PT*?0T*
`
end


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