Using MPL to write is_derived_from_std_basic_ostream

I'm trying to ascertain whether a given class is, or is derived from, std::basic_ostream, but I've ground to a halt. The attached code successfully reports those classes that do derive from std::basic_ostream but fails to compile when I test std::string, bool, char etc. I can see what is going wrong, but have run out of ideas about how to fix it. I'm also painfully aware that my attempts are just plain ugly. Can someone show me the way forward? Regards, Angus

"Angus Leeming" <angus.leeming@btopenworld.com> wrote in message news:ch7h3d$466$1@sea.gmane.org...
I'm trying to ascertain whether a given class is, or is derived from, std::basic_ostream, but I've ground to a halt.
The attached file ios_traits.hpp is from my iostreams library currently under review. It contains MPL-compatible metafunctions is_istream, is_ostream, is_iostream and is_streambuf to test whether a given type is the same as or derived from the corresponding standard library template. It has served me well, but I'd be happy to have others examine it. Note that it is fairly common for a stream to derive privately from basic_streambuf; with the current implementation, testing such a stream using is_streambuf causes a compiler error. Jonathan begin 666 ios_traits.hpp M+R\@*$,I($-O<'ER:6=H="!*;VYA=&AA;B!4=7)K86YI<R R,# S+@T*+R\@ M1&ES=')I8G5T960@=6YD97(@=&AE($)O;W-T(%-O9G1W87)E($QI8V5N<V4L M(%9E<G-I;VX@,2XP+B H4V5E(&%C8V]M<&%N>6EN9PT*+R\@9FEL92!,24-% M3E-%7S%?,"YT>'0@;W(@8V]P>2!A="!H='1P.B\O=W=W+F)O;W-T+F]R9R], M24-%3E-%7S%?,"YT>'0N*0T*#0HC:69N9&5F($)/3U-47TE/7TE/4U]44D%) M5%-?2%!07TE.0TQ51$5$#0HC9&5F:6YE($)/3U-47TE/7TE/4U]44D%)5%-? M2%!07TE.0TQ51$5$(" @(" @( T*( T*(VEN8VQU9&4@/&ET97)A=&]R/B @ M(" @(" @(" @(" @(" @(" @(" @(" @(" O+R!B86-K7VEN<V5R=%]I=&5R M871O<BX@(" @#0HC:6YC;'5D92 \:6]S9G=D/@T*(VEN8VQU9&4@/&)O;W-T M+V-O;F9I9RYH<' ^(" @(" @(" @(" @(" @(" @(" O+R!S=&%T:6,@8V]N M<W0N#0HC:6YC;'5D92 \8F]O<W0O;7!L+V%U>%\O;&%M8F1A7W-U<'!O<G0N M:'!P/B @(" @(" @(" @(" @( T*(VEN8VQU9&4@/&)O;W-T+VUP;"]B;V]L M+FAP<#X@(" @(" @(" @(" @(" -"B-I;F-L=61E(#QB;V]S="]M<&PO;W(N M:'!P/B @(" @(" @(" @(" @( T*(VEN8VQU9&4@/&)O;W-T+W!R97!R;V-E M<W-O<B]C870N:'!P/B @(" @(" @(" -"B-I;F-L=61E(#QB;V]S="]P<F5P M<F]C97-S;W(O<F5P971I=&EO;B]E;G5M7W!A<F%M<RYH<' ^(" @(" @(" - M"B-I;F-L=61E(#QB;V]S="]T>7!E7W1R86ET<R]I<U]B87-E7V%N9%]D97)I M=F5D+FAP<#X@(" @(" @(" @(" -"B-I;F-L=61E(#QB;V]S="]T>7!E7W1R M86ET<R]I<U]S86UE+FAP<#X@(" @(" @(" @(" @#0HC:6YC;'5D92 \8F]O M<W0O='EP95]T<F%I=',O9&5T86EL+WEE<U]N;U]T>7!E+FAP<#X@(" @( T* M#0HO+R -"B\O($UA8W)O(&YA;64Z($)/3U-47TE/7T)/3TQ?5%)!251?1$5& M#0HO+R!$97-C<FEP=&EO;CH@57-E9"!T;R!G96YE<F%T92!T:&4@=')A:71S M(&-L87-S97,@:7-?:7-T<F5A;2P@:7-?;W-T<F5A;2P-"B\O(" @(" @971C M+@T*+R\-"B-D969I;F4@0D]/4U1?24]?0D]/3%]44D%)5%]$148H=')A:70L M('1Y<&4L(&%R:71Y*2 @(" @(" @(" @(" @(" @(" @(" @("!<#0H@(" @ M;F%M97-P86-E(&)O;W-T('L@;F%M97-P86-E(&EO('L@;F%M97-P86-E(&1E M=&%I;"![(" @(" @(" @(" @(" @(" @(" @7 T*(" @(" @=&5M<&QA=&4\ M0D]/4U1?4%!?14Y535]005)!35,H87)I='DL('1Y<&5N86UE(%0I/B @(" @ M(" @(" @(" @(" @(" @(%P-"B @(" @('1Y<&5?=')A:71S.CIY97-?='EP M92!"3T]35%]04%]#050H=')A:70L(%]H96QP97(I(" @(" @(" @(" @(" @ M(" @("!<#0H@(" @(" @(" @*&-O;G-T('9O;&%T:6QE('1Y<&4\0D]/4U1? M4%!?14Y535]005)!35,H87)I='DL(%0I/BHI.R @(" @(" @(" @7 T*(" @ M(" @='EP95]T<F%I=',Z.FYO7W1Y<&4@0D]/4U1?4%!?0T%4*'1R86ET+"!? M:&5L<&5R*2@N+BXI.R @(" @(" @(" @(" @(%P-"B @(" @('1E;7!L871E M/'1Y<&5N86UE(%0^(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @("!<#0H@(" @("!S=')U8W0@0D]/4U1?4%!?0T%4 M*'1R86ET+"!?:6UP;"D@>R @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @7 T*(" @(" @(" @("!"3T]35%]35$%424-?0T].4U1!3E0H8F]O M;"P@=F%L=64@/2 @(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @ M(" @(" @(" @(" @("AS:7IE;V8H0D]/4U1?4%!?0T%4*'1R86ET+"!?:&5L M<&5R*2AS=&%T:6-?8V%S=#Q4*CXH,"DI*2 ]/2!<#0H@(" @(" @(" @(" @ M(" @<VEZ96]F*'1Y<&5?=')A:71S.CIY97-?='EP92DI*3L@(" @(" @(" @ M(" @(" @(" @(" @(" @(" @7 T*(" @(" @?3L@(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(%P-"B @("!](" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @("!<#0H@ M(" @=&5M<&QA=&4\='EP96YA;64@5#X@(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @7 T*(" @('-T<G5C="!T M<F%I=" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(%P-"B @(" @(" @.B!M<&PZ.F)O;VQ?/&1E M=&%I;#HZ0D]/4U1?4%!?0T%4*'1R86ET+"!?:6UP;"D\5#XZ.G9A;'5E/B @ M(" @(" @("!<#0H@(" @>R!"3T]35%]-4$Q?05587TQ!34)$05]355!03U)4 M*#$L('1R86ET+" H5"DI('T[(" @(" @(" @(" @(" @(" @(" @(" @7 T* M(" @('T@?2 @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @(" O*BHO#0H- M"D)/3U-47TE/7T)/3TQ?5%)!251?1$5&*&ES7V)A8VM?:6YS97)T97(L('-T M9#HZ8F%C:U]I;G-E<G1?:71E<F%T;W(L(#$I#0I"3T]35%])3U]"3T],7U12 M04E47T1%1BAI<U]I<W1R96%M+"!S=&0Z.F)A<VEC7VES=')E86TL(#(I#0I" M3T]35%])3U]"3T],7U1204E47T1%1BAI<U]O<W1R96%M+"!S=&0Z.F)A<VEC M7V]S=')E86TL(#(I#0I"3T]35%])3U]"3T],7U1204E47T1%1BAI<U]I;W-T M<F5A;2P@<W1D.CIB87-I8U]I;W-T<F5A;2P@,BD-"D)/3U-47TE/7T)/3TQ? M5%)!251?1$5&*&ES7W-T<F5A;6)U9BP@<W1D.CIB87-I8U]S=')E86UB=68L M(#(I#0I"3T]35%])3U]"3T],7U1204E47T1%1BAI<U]S=')I;F=S=')E86TL M('-T9#HZ8F%S:6-?<W1R:6YG<W1R96%M+" S*0T*0D]/4U1?24]?0D]/3%]4 M4D%)5%]$148H:7-?<W1R:6YG8G5F+"!S=&0Z.F)A<VEC7W-T<FEN9V)U9BP@ M,RD-"@T*;F%M97-P86-E(&)O;W-T('L@;F%M97-P86-E(&EO('L@#0H-"B\O M#0HO+R!496UP;&%T92!N86UE.B!I<U]S=')E86TN#0HO+R!$97-C<FEP=&EO M;CH@5'EP92!T<F%I=',@=&5M<&QA=&4@<F5T=7)N:6YG('1R=64@:68@5"!I M<R!T:&4@<V%M92!A<R!O<@T*+R\@(" @("!D97)I=F5D(&9R;VT@82!S<&5C M:6%L:7IA=&EO;B!O9B!S=&0Z.F)A<VEC7VES=')E86TL('-T9#HZ8F%S:6-? M;W-T<F5A;0T*+R\@(" @("!O<B!S=&0Z.F)A<VEC7W-T<F5A;6)U9BX@26=N M;W)E<R!C=BUQ=6%L:69I97)S+@T*+R\@3F]T93H@268@5"!D97)I=F5S(&YO M;BUP=6)L:6-L>2!F<F]M(&$@<W!E:6-I86QI>F%T:6]N(&]F(&)A<VEC7W-T M<F5A;6)U9BP-"B\O(" @(" @=&AE(&5X<')E<W-I;VX@:7-?<W1R96%M8G5F M/%0^.CIT>7!E('=I;&P@8V%U<V4@82!C;VUP:6QE<B!E<G)O<BX@4VEN8V4- M"B\O(" @(" @:70@:7,@8V]M;6]N(&9O<B!S=')E86US('1O(&1E<FEV92!P M<FEV871E;'D@9G)O;2!B87-I8U]S=')E86UB=68L#0HO+R @(" @(&ES7W-T M<F5A;6)U9B!M=7-T(&-O;64@;&%S="!I;B!T:&4@9&ES:G5N8W1I;VX@8F5L M;W<N#0HO+PT*=&5M<&QA=&4\='EP96YA;64@5#X-"G-T<G5C="!I<U]S=&1? M:6\-"B @(" Z(&UP;#HZ;W)?/"!I<U]I<W1R96%M/%0^+"!I<U]O<W1R96%M M/%0^+"!I<U]S=')E86UB=68\5#X@/@T*(" @('L@?3L-"@T*?2!]("\O($5N M9"!N86UE<W!A8V4@8F]O<W0L(&EO+@T*#0HC96YD:68@+R\@(VEF;F1E9B!" A3T]35%])3U])3U-?5%)!25137TA04%])3D-,541%1 T* ` end

On 9/2/04 12:40 PM, "Jonathan Turkanis" <technews@kangaroologic.com> wrote: [SNIP]
Note that it is fairly common for a stream to derive privately from basic_streambuf; with the current implementation, testing such a stream using is_streambuf causes a compiler error.
I think that using private inheritance as an quick & dirty containment strategy is a bad idea in general. (Which includes this usage.) All the member names of the contained object's class get injected as member names of the container object's class. Also, the container object's member functions (and friends) still see the relationship as IS-A, even though it's supposed to be HAS-A, so inappropriate conversions and/or uses won't be checked. -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com

"Daryle Walker" <darylew@hotmail.com> wrote in message news:BD6112DB.EF56%darylew@hotmail.com...
On 9/2/04 12:40 PM, "Jonathan Turkanis" <technews@kangaroologic.com> wrote:
[SNIP]
Note that it is fairly common for a stream to derive privately from basic_streambuf; with the current implementation, testing such a stream using is_streambuf causes a compiler error.
I think that using private inheritance as an quick & dirty containment strategy is a bad idea in general. (Which includes this usage.) All the member names of the contained object's class get injected as member names of the container object's class. Also, the container object's member functions (and friends) still see the relationship as IS-A, even though it's supposed to be HAS-A, so inappropriate conversions and/or uses won't be checked.
The problem is that you get a compiler error just for asking the question: is T a streambuf? T may be written by someone else; you shouldn't have to assume anything about it. Jonathan

"Angus Leeming" <angus.leeming@btopenworld.com> wrote in message news:ch7h3d$466$1@sea.gmane.org...
I'm trying to ascertain whether a given class is, or is derived from, std::basic_ostream, but I've ground to a halt.
I've attached a somewhat improved version inspired by your attempt. (Thanks!) It only works on compilers which support has_xxx, but it should handle the case of private inheritance now, by delegating to is_base_and_derived. Note that with the current cvs it should not be necessary to write mpl::and_< mpl::bool_<has_char_type<U>::value>, ... You can simply say mpl::and_< has_char_type<U>, ... Best Regards, Jonathan begin 666 ios_traits.hpp M+R\@*$,I($-O<'ER:6=H="!*;VYA=&AA;B!4=7)K86YI<R R,# S+@T*+R\@ M1&ES=')I8G5T960@=6YD97(@=&AE($)O;W-T(%-O9G1W87)E($QI8V5N<V4L M(%9E<G-I;VX@,2XP+B H4V5E(&%C8V]M<&%N>6EN9PT*+R\@9FEL92!,24-% M3E-%7S%?,"YT>'0@;W(@8V]P>2!A="!H='1P.B\O=W=W+F)O;W-T+F]R9R], M24-%3E-%7S%?,"YT>'0N*0T*#0HC:69N9&5F($)/3U-47TE/7TE/4U]44D%) M5%-?2%!07TE.0TQ51$5$#0HC9&5F:6YE($)/3U-47TE/7TE/4U]44D%)5%-? M2%!07TE.0TQ51$5$(" @(" @( T*( T*(VEN8VQU9&4@/&ET97)A=&]R/B @ M(" @(" @(" @(" @(" @(" @(" @(" @(" O+R!B86-K7VEN<V5R=%]I=&5R M871O<BX@(" @#0HC:6YC;'5D92 \:6]S9G=D/@T*(VEN8VQU9&4@/&)O;W-T M+V-O;F9I9RYH<' ^(" @(" @(" @(" @(" @(" @(" O+R!S=&%T:6,@8V]N M<W0N#0HC:6YC;'5D92 \8F]O<W0O;7!L+V%U>%\O:&%S7WAX>"YH<' ^(" @ M(" @(" @(" @(" @#0HC:6YC;'5D92 \8F]O<W0O;7!L+V%U>%\O;&%M8F1A M7W-U<'!O<G0N:'!P/B @( T*(VEN8VQU9&4@/&)O;W-T+VUP;"]A;F0N:'!P M/B @(" @(" @(" @(" @( T*(VEN8VQU9&4@/&)O;W-T+VUP;"]B;V]L+FAP M<#X@(" @(" @(" @(" @(" -"B-I;F-L=61E(#QB;V]S="]M<&PO;W(N:'!P M/B @(" @(" @(" @(" @( T*(VEN8VQU9&4@/&)O;W-T+W!R97!R;V-E<W-O M<B]C870N:'!P/B @(" @(" @(" -"B-I;F-L=61E(#QB;V]S="]P<F5P<F]C M97-S;W(O<F5P971I=&EO;B]E;G5M7W!A<F%M<RYH<' ^(" @(" @(" -"B-I M;F-L=61E(#QB;V]S="]T>7!E7W1R86ET<R]I<U]B87-E7V%N9%]D97)I=F5D M+FAP<#X@(" @(" @(" @(" -"B-I;F-L=61E(#QB;V]S="]T>7!E7W1R86ET M<R]I<U]S86UE+FAP<#X@(" @(" @(" @(" @#0HC:6YC;'5D92 \8F]O<W0O M='EP95]T<F%I=',O9&5T86EL+WEE<U]N;U]T>7!E+FAP<#X@(" @( T*#0HO M+R -"B\O($UA8W)O(&YA;64Z($)/3U-47TE/7T)/3TQ?5%)!251?1$5HO M+R!$97-C<FEP=&EO;CH@57-E9"!T;R!G96YE<F%T92!T:&4@=')A:71S(&-L M87-S97,@:7-?:7-T<F5A;2P@:7-?;W-T<F5A;2P-"B\O(" @(" @971C+@T* M+R\-"B-D969I;F4@0D]/4U1?24]?0D]/3%]44D%)5%]$148H=')A:70L('1Y M<&4L(&%R:71Y*2 @(" @(" @(" @(" @(" @(" @(" @("!<#0H@(" @;F%M M97-P86-E(&)O;W-T('L@;F%M97-P86-E(&EO('L@;F%M97-P86-E(&1E=&%I M;"![(" @(" @(" @(" @(" @(" @(" @7 T*(" @(" @=&5M<&QA=&4\0D]/ M4U1?4%!?14Y535]005)!35,H87)I='DL('1Y<&5N86UE(%0I/B @(" @(" @ M(" @(" @(" @(" @(%P-"B @(" @('1Y<&5?=')A:71S.CIY97-?='EP92!" M3T]35%]04%]#050H=')A:70L(%]H96QP97(I(" @(" @(" @(" @(" @(" @ M("!<#0H@(" @(" @(" @*&-O;G-T('9O;&%T:6QE('1Y<&4\0D]/4U1?4%!? M14Y535]005)!35,H87)I='DL(%0I/BHI.R @(" @(" @(" @7 T*(" @(" @ M='EP95]T<F%I=',Z.FYO7W1Y<&4@0D]/4U1?4%!?0T%4*'1R86ET+"!?:&5L M<&5R*2@N+BXI.R @(" @(" @(" @(" @(%P-"B @(" @('1E;7!L871E/'1Y M<&5N86UE(%0^(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @("!<#0H@(" @("!S=')U8W0@0D]/4U1?4%!?0T%4*'1R M86ET+"!?:6UP;"D@>R @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @7 T*(" @(" @(" @("!"3T]35%]35$%424-?0T].4U1!3E0H8F]O;"P@ M=F%L=64@/2 @(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @(" @ M(" @(" @(" @("AS:7IE;V8H0D]/4U1?4%!?0T%4*'1R86ET+"!?:&5L<&5R M*2AS=&%T:6-?8V%S=#Q4*CXH,"DI*2 ]/2!<#0H@(" @(" @(" @(" @(" @ M<VEZ96]F*'1Y<&5?=')A:71S.CIY97-?='EP92DI*3L@(" @(" @(" @(" @ M(" @(" @(" @(" @(" @7 T*(" @(" @?3L@(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(%P-"B @("!](" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @("!<#0H@(" @ M=&5M<&QA=&4\='EP96YA;64@5#X@(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @7 T*(" @('-T<G5C="!T<F%I M=" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(%P-"B @(" @(" @.B!M<&PZ.F)O;VQ?/&1E=&%I M;#HZ0D]/4U1?4%!?0T%4*'1R86ET+"!?:6UP;"D\5#XZ.G9A;'5E/B @(" @ M(" @("!<#0H@(" @>R!"3T]35%]-4$Q?05587TQ!34)$05]355!03U)4*#$L M('1R86ET+" H5"DI('T[(" @(" @(" @(" @(" @(" @(" @(" @7 T*(" @ M('T@?2 @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @(" O*BHO#0H-"FYA M;65S<&%C92!B;V]S="![(&YA;65S<&%C92!I;R![(&YA;65S<&%C92!D971A M:6P@>PT*#0I"3T]35%]-4$Q?2$%37UA86%]44D%)5%].04U%1%]$148H:&%S M7V-H87)?='EP92P@8VAA<E]T>7!E+"!T<G5E*0T*0D]/4U1?35!,7TA!4U]8 M6%A?5%)!251?3D%-141?1$5&*&AA<U]T<F%I='-?='EP92P@=')A:71S7W1Y M<&4L('1R=64I#0H-"GT@?2!]("\O($5N9"!N86UE<W!A8V5S(&1E=&%I;"P@ M:6\L(&)O;W-T+@T*#0HO+R -"B\O($UA8W)O(&YA;64Z($)/3U-47TE/7T)/ M3TQ?5%)!251?1$5HO+R!$97-C<FEP=&EO;CH@57-E9"!T;R!G96YE<F%T M92!T:&4@=')A:71S(&-L87-S97,@:7-?:7-T<F5A;2P@:7-?;W-T<F5A;2P- M"B\O(" @(" @971C+@T*+R\-"B-D969I;F4@0D]/4U1?24]?24]37U1204E4 M7T1%1BAT<F%I="P@8F%S92D@(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @("!<#0H@(" @;F%M97-P86-E(&)O;W-T('L@;F%M97-P86-E(&EO('L@ M;F%M97-P86-E(&1E=&%I;"![(" @(" @(" @(" @(" @(" @(" @7 T*(" @ M(" @=&5M<&QA=&4\='EP96YA;64@5#X@(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @(" @('-T<G5C="!" M3T]35%]04%]#050H=')A:70L(%]I;7!L*2![(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @("!<#0H@(" @(" @(" @=&5M<&QA=&4\='EP96YA M;64@53X@(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @7 T*(" @(" @(" @('-T<G5C="!D97)I=F5D7V9R;VU?8F%S92![ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @ M(" @(" @(" @(" @='EP961E9B!T>7!E;F%M92!5.CIC:&%R7W1Y<&4@(" @ M(" @(" @(" @(" @(" @(&-H87)?='EP93L@("!<#0H@(" @(" @(" @(" @ M('1Y<&5D968@='EP96YA;64@53HZ=')A:71S7W1Y<&4@(" @(" @(" @(" @ M(" @("!T<F%I='-?='EP93L@7 T*(" @(" @(" @(" @("!T>7!E9&5F(&UP M;#HZ;W)?/" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(%P-"B @(" @(" @(" @(" @(" @(" @(" @(" @:7-?<V%M93P@ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @("!<#0H@ M(" @(" @(" @(" @(" @(" @(" @(" @(" @("!B87-E/&-H87)?='EP92P@ M=')A:71S7W1Y<&4^+"!5(" @(" @(" @(" @(" @7 T*(" @(" @(" @(" @ M(" @(" @(" @(" @(" ^+" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(%P-"B @(" @(" @(" @(" @(" @(" @(" @ M(" @:7-?8F%S95]A;F1?9&5R:79E9#P@(" @(" @(" @(" @(" @(" @(" @ M(" @(" @("!<#0H@(" @(" @(" @(" @(" @(" @(" @(" @(" @("!B87-E M/&-H87)?='EP92P@=')A:71S7W1Y<&4^+"!5(" @(" @(" @(" @(" @7 T* M(" @(" @(" @(" @(" @(" @(" @(" @(" ^(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @(" @(" @(" @ M(" @(" @(" @(" ^(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @('1Y<&4[(" @(" @("!<#0H@(" @(" @(" @(" @($)/3U-47U-4 M051)0U]#3TY35$%.5"AB;V]L+"!V86QU92 ]('1Y<&4Z.G9A;'5E*3L@(" @ M(" @(" @(" @7 T*(" @(" @(" @('T[(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P- M"B @(" @(" @("!T>7!E9&5F(&UP;#HZ86YD7SP@(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @("!<#0H@(" @(" @(" @ M(" @(" @(" @(" @(&UP;#HZ8F]O;%\\:&%S7V-H87)?='EP93Q4/CHZ=F%L M=64^+" @(" @(" @(" @(" @(" @7 T*(" @(" @(" @(" @(" @(" @(" @ M("!M<&PZ.F)O;VQ?/&AA<U]T<F%I='-?='EP93Q4/CHZ=F%L=64^+" @(" @ M(" @(" @(" @(%P-"B @(" @(" @(" @(" @(" @(" @(" @9&5R:79E9%]F M<F]M7V)A<V4\5#X@(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @("!< M#0H@(" @(" @(" @(" @(" @(" ^(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @("!T>7!E.R @(" @(" @7 T*(" @(" @(" @ M($)/3U-47U-4051)0U]#3TY35$%.5"AB;V]L+"!V86QU92 ]('1Y<&4Z.G9A M;'5E*3L@(" @(" @(" @(" @(" @(%P-"B @(" @('T[(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @("!<#0H@(" @?2 @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M7 T*(" @('1E;7!L871E/'1Y<&5N86UE(%0^(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(%P-"B @("!S=')U M8W0@=')A:70@(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @("!<#0H@(" @(" @(#H@;7!L.CIB;V]L M7SQD971A:6PZ.D)/3U-47U!07T-!5"AT<F%I="P@7VEM<&PI/%0^.CIV86QU M93X@(" @(" @(" @7 T*(" @('L@0D]/4U1?35!,7T%56%],04U"1$%?4U50 M4$]25"@Q+"!T<F%I="P@*%0I*2!].R @(" @(" @(" @(" @(" @(" @(" @ M(%P-"B @("!]('T@(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @("!<#0H@(" @+RHJ M+PT*#0I"3T]35%])3U]"3T],7U1204E47T1%1BAI<U]B86-K7VEN<V5R=&5R M+"!S=&0Z.F)A8VM?:6YS97)T7VET97)A=&]R+" Q*0T*0D]/4U1?24]?24]3 M7U1204E47T1%1BAI<U]I<W1R96%M+"!S=&0Z.F)A<VEC7VES=')E86TI#0I" M3T]35%])3U])3U-?5%)!251?1$5&*&ES7V]S=')E86TL('-T9#HZ8F%S:6-? M;W-T<F5A;2D-"D)/3U-47TE/7TE/4U]44D%)5%]$148H:7-?:6]S=')E86TL M('-T9#HZ8F%S:6-?:6]S=')E86TI#0I"3T]35%])3U])3U-?5%)!251?1$5& M*&ES7W-T<F5A;6)U9BP@<W1D.CIB87-I8U]S=')E86UB=68I#0I"3T]35%]) M3U]"3T],7U1204E47T1%1BAI<U]S=')I;F=S=')E86TL('-T9#HZ8F%S:6-? M<W1R:6YG<W1R96%M+" S*0T*0D]/4U1?24]?0D]/3%]44D%)5%]$148H:7-? M<W1R:6YG8G5F+"!S=&0Z.F)A<VEC7W-T<FEN9V)U9BP@,RD-"@T*;F%M97-P M86-E(&)O;W-T('L@;F%M97-P86-E(&EO('L@#0H-"B\O#0HO+R!496UP;&%T M92!N86UE.B!I<U]S=')E86TN#0HO+R!$97-C<FEP=&EO;CH@5'EP92!T<F%I M=',@=&5M<&QA=&4@<F5T=7)N:6YG('1R=64@:68@5"!I<R!T:&4@<V%M92!A M<R!O<@T*+R\@(" @("!D97)I=F5D(&9R;VT@82!S<&5C:6%L:7IA=&EO;B!O M9B!S=&0Z.F)A<VEC7VES=')E86TL('-T9#HZ8F%S:6-?;W-T<F5A;0T*+R\@ M(" @("!O<B!S=&0Z.F)A<VEC7W-T<F5A;6)U9BX@26=N;W)E<R!C=BUQ=6%L M:69I97)S+@T*+R\@3F]T93H@268@5"!D97)I=F5S(&YO;BUP=6)L:6-L>2!F M<F]M(&$@<W!E:6-I86QI>F%T:6]N(&]F(&)A<VEC7W-T<F5A;6)U9BP-"B\O M(" @(" @=&AE(&5X<')E<W-I;VX@:7-?<W1R96%M8G5F/%0^.CIT>7!E('=I M;&P@8V%U<V4@82!C;VUP:6QE<B!E<G)O<BX@4VEN8V4-"B\O(" @(" @:70@ M:7,@8V]M;6]N(&9O<B!S=')E86US('1O(&1E<FEV92!P<FEV871E;'D@9G)O M;2!B87-I8U]S=')E86UB=68L#0HO+R @(" @(&ES7W-T<F5A;6)U9B!M=7-T M(&-O;64@;&%S="!I;B!T:&4@9&ES:G5N8W1I;VX@8F5L;W<N#0HO+PT*=&5M M<&QA=&4\='EP96YA;64@5#X-"G-T<G5C="!I<U]S=&1?:6\-"B @(" Z(&UP M;#HZ;W)?/"!I<U]I<W1R96%M/%0^+"!I<U]O<W1R96%M/%0^+"!I<U]S=')E M86UB=68\5#X@/@T*(" @('L@?3L-"@T*?2!]("\O($5N9"!N86UE<W!A8V4@ M8F]O<W0L(&EO+@T*#0HC96YD:68@+R\@(VEF;F1E9B!"3T]35%])3U])3U-? 55%)!25137TA04%])3D-,541%1 T* ` end

"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"Angus Leeming" <angus.leeming@btopenworld.com> wrote in message news:ch7h3d$466$1@sea.gmane.org...
I'm trying to ascertain whether a given class is, or is derived from, std::basic_ostream, but I've ground to a halt.
I've attached a somewhat improved version inspired by your attempt. (Thanks!) It only works on compilers which support has_xxx, but it should handle the case of private inheritance now, by delegating to is_base_and_derived.
Note that with the current cvs it should not be necessary to write
mpl::and_< mpl::bool_<has_char_type<U>::value>, ...
You can simply say
mpl::and_< has_char_type<U>, ...
It's hard for me to understand why you would need has_xxx for this purpose, or how you would use it. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

"David Abrahams" <dave@boost-consulting.com> wrote in message news:un008whj3.fsf@boost-consulting.com...
"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"Angus Leeming" <angus.leeming@btopenworld.com> wrote in message news:ch7h3d$466$1@sea.gmane.org...
I'm trying to ascertain whether a given class is, or is derived from, std::basic_ostream, but I've ground to a halt.
Note that with the current cvs it should not be necessary to write
mpl::and_< mpl::bool_<has_char_type<U>::value>, ...
You can simply say
mpl::and_< has_char_type<U>, ...
It's hard for me to understand why you would need has_xxx for this purpose, or how you would use it.
Well, you could look at the attachment .... ;-) An arbitrary type T is equal to or derived from a specialization of std::basic_ostream iff (almost): (i) it has a member type char_type; (ii) it has a member type traits_type; and (iii) either: (a) it is the same as basic_ostream<T::char_type, T::traits_type>, OR (b) it is derived from basic_ostream<T::char_type, T::traits_type> This asumes that T doesn't have different member types char_type or traits_type which hide those inherited from std::basic_ostream. There's and easier way to do this (featured in the first attachment), but it get's in trouble with private derivation. If you have a simpler or more correct way, please let me know. Jonathan

"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"David Abrahams" <dave@boost-consulting.com> wrote in message news:un008whj3.fsf@boost-consulting.com...
"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"Angus Leeming" <angus.leeming@btopenworld.com> wrote in message news:ch7h3d$466$1@sea.gmane.org...
I'm trying to ascertain whether a given class is, or is derived from, std::basic_ostream, but I've ground to a halt.
Note that with the current cvs it should not be necessary to write
mpl::and_< mpl::bool_<has_char_type<U>::value>, ...
You can simply say
mpl::and_< has_char_type<U>, ...
It's hard for me to understand why you would need has_xxx for this purpose, or how you would use it.
Well, you could look at the attachment .... ;-)
I did, but got mired in details.
An arbitrary type T is equal to or derived from a specialization of std::basic_ostream iff (almost):
(i) it has a member type char_type; (ii) it has a member type traits_type; and (iii) either: (a) it is the same as basic_ostream<T::char_type, T::traits_type>, OR (b) it is derived from basic_ostream<T::char_type, T::traits_type>
This asumes that T doesn't have different member types char_type or traits_type which hide those inherited from std::basic_ostream.
Why not just copy the implementation of is_base_and_derived and templatize the conversion operators in the Host class? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

"David Abrahams" <dave@boost-consulting.com> wrote in message:
"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"David Abrahams" <dave@boost-consulting.com> wrote in message
It's hard for me to understand why you would need has_xxx for this purpose, or how you would use it.
Well, you could look at the attachment .... ;-)
I did, but got mired in details.
<snip>
Why not just copy the implementation of is_base_and_derived and templatize the conversion operators in the Host class?
I thought of that. I liked the posted version because it just uses out-of-the box components. Maybe it just doesn't look mired in details to me because I wrote it :-). BTW, the first macro BOOST_IO_BOOL_TRAIT_DEF in the attachement is not relevant to the current discussion. The macro BOOST_IO_IOS_TRAIT_DEF conatins the entire implementation of the above technique. Jonathan

Jonathan Turkanis wrote:
"Angus Leeming" <angus.leeming@btopenworld.com> wrote in message news:ch7h3d$466$1@sea.gmane.org...
I'm trying to ascertain whether a given class is, or is derived from, std::basic_ostream, but I've ground to a halt.
I've attached a somewhat improved version inspired by your attempt. (Thanks!)
Hey! ;-)
It only works on compilers which support has_xxx, but it should handle the case of private inheritance now, by delegating to is_base_and_derived.
Hmmmmm. Looking at your solution, I can see that I was on the right track. What puzzles me is why my attempt fails and yours succeeds. Mine complains that 'bool' has no char_traits member when I try is_ostream<bool> Yours just works. Ahhh. I think I get it. Yours is all wrapped up inside template<typename T> struct is_ostream : mpl::bool_<detail::is_ostream_impl<T>::value> {}; Clever, clever, clever.
Note that with the current cvs it should not be necessary to write mpl::and_< mpl::bool_<has_char_type<U>::value>, ... You can simply say mpl::and_< has_char_type<U>, ...
Oh, great. I didn't think to look in the aux_ directory and so never spotted has_xxx.hpp. Many, many thanks for all this, Jonathan. Angus
participants (4)
-
Angus Leeming
-
Daryle Walker
-
David Abrahams
-
Jonathan Turkanis