|
Boost Users : |
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-09-02 17:49:48
"David Abrahams" <dave_at_[hidden]> wrote in message
news:un008whj3.fsf_at_boost-consulting.com...
> "Jonathan Turkanis" <technews_at_[hidden]> writes:
>
> > "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.
> >
> > 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
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