|
Boost : |
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-02-09 14:27:47
"Jonathan Turkanis" <technews_at_[hidden]> wrote in message
news:cub5f6$ulc$1_at_sea.gmane.org...
| Thorsten Ottosen wrote:
| > That is often a problem because of multiple overloads, that is,
| > we get ambiguity. Basically I think we got two alternatives:
| >
| > 1.
| > template< class Iter >
| > void container::assign( const iterator_range<Iter>& );
| > ...
| > container c;
| > c.assign( make_iterator_range( some_range ) );
| >
| > 2.
| >
| > template< class Range
| > void container::assign_range( const Range& ):
| > ....
| > container c;
| > c.assign_range( some_range );
| >
| > Which one do you prefer?
|
| I definitely prefer "assign" to "assign_range". Could you say more explcitly
| what the ambiguity would be if you try to make assign and insert to too much
| work?
yes, the problem shows up when an implicit conversion from Derived* to Base*
is needed and when another templated overload exists. The templated overload
does not require any conversions and so is deemed a better match.
The attached code shows the problem.
I guess the problem could be removed with disable_if<>.
-Thorsten
begin 666 range.cpp
M(VEN8VQU9&4@/'9E8W1O<CX-"B-I;F-L=61E(#QB;V]S="]T>7!E7W1R86ET
M<R]I<U]P;VEN=&5R+FAP<#X-"B-I;F-L=61E(#QB;V]S="]S=&%T:6-?87-S
M97)T+FAP<#X-"@T*=&5M<&QA=&4\(&-L87-S(%0@/@T*<W1R=6-T(&YE=U]V
M96-T;W(-"GL-"B @("!T>7!E9&5F('-T9#HZ=F5C=&]R/%0J/B @(" @(" @
M(" @("!T>7!E.PT*(" @('1Y<&5D968@='EP96YA;64@='EP93HZ:71E<F%T
M;W(@(" @(&ET97)A=&]R.PT*#0H@(" @=F]I9"!I;G-E<G0H(&ET97)A=&]R
M+"!4*B I#0H@(" @>PT*(" @('T-"@T*(" @('9O:60@:6YS97)T*"!I=&5R
M871O<BP_at_5"8@*0T*(" @('L-"B @("!]#0H-"B @("!T96UP;&%T93P_at_8VQA
M<W,@4F%N9V4@/@T*(" @('9O:60@:6YS97)T*"!I=&5R871O<BP_at_8V]N<W0@
M4F%N9V4F('(@*0T*(" @('L-"B @(" @(" @0D]/4U1?4U1!5$E#7T%34T52
M5"@H("%B;V]S=#HZ:7-?<&]I;G1E<CQ286YG93XZ.G9A;'5E("DI.PT*(" @
M('T-"@T*(" @(&ET97)A=&]R(&)E9VEN*"D-"B @("![#0H@(" @(" @(')E
M='5R;B!I=&5R871O<B_at_[hidden]*(" @('T-"GT[#0H-"G-T<G5C="!&;V\-"GL-
M"GT[#0H-"G-T<G5C="!"87(@.B!&;V\-"GL-"GT[#0H-"G1E;7!L871E/"!C
M;&%S<R!4+"!C;&%S<R!5(#X-"G9O:60_at_9F]O*"D-"GL-"B @("!N97=?=F5C
M=&]R/%0^('8[#0H@(" @=BYI;G-E<G0H('8N8F5G:6XH*2P@;F5W(%4@*3L@
M(" @#0H@(" @=BYI;G-E<G0H('8N8F5G:6XH*2P@=B I.PT*?0T*#0II;G0@
M;6%I;B_at_I#0I[#0H-"B @("!F;V\\:6YT+&EN=#XH*3L@+R\@;VL-"B @("!F
M;V\\1F]O+$9O;SXH*3L@+R\@;VL-"B @("!F;V\\1F]O+$)A<CXH*3L@+R\@
*9&]H#0H-"GT-"@``
`
end
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk