Boost logo

Boost Users :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-09-02 11:40:04


"Angus Leeming" <angus.leeming_at_[hidden]> wrote in message
news:ch7h3d$466$1_at_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_at_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_at_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_at_0D]/4U1?4%!?0T%4*'1R86ET+"!?
M:&5L<&5R*2_at_N+BXI.R @(" @(" @(" @(" @(%P-"B @(" @('1E;7!L871E
M/'1Y<&5N86UE(%0^(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @
M(" @(" @(" @(" @(" @("!<#0H@(" @("!S=')U8W0_at_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_at_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_at_5'EP92!T<F%I=',@=&5M<&QA=&4@<F5T=7)N:6YG('1R=64@:68_at_5"!I
M<R!T:&4@<V%M92!A<R!O<@T*+R\@(" @("!D97)I=F5D(&9R;VT_at_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_at_26=N
M;W)E<R!C=BUQ=6%L:69I97)S+@T*+R\@3F]T93H_at_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_at_8V%U<V4_at_82!C;VUP:6QE<B!E<G)O<BX_at_4VEN8V4-
M"B\O(" @(" @:70@:7,@8V]M;6]N(&9O<B!S=')E86US('1O(&1E<FEV92!P
M<FEV871E;'D_at_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_at_9&ES:G5N8W1I;VX_at_8F5L
M;W<N#0HO+PT*=&5M<&QA=&4\='EP96YA;64_at_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_at_8F]O<W0L(&EO+@T*#0HC96YD:68@+R\@(VEF;F1E9B!"
A3T]35%])3U])3U-?5%)!25137TA04%])3D-,541%1 T*
`
end


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net