|
Boost Users : |
From: Wolfgang Meyer (Wolfgang.Meyer_at_[hidden])
Date: 2004-05-11 17:26:12
On Tuesday 11 May 2004 19:09, Rozental, Gennadiy wrote:
> > It already works. If you want to detect STL sequence-ness, you'll
> > have to try some nasty hacks. I'm have doubts about whether it's even
> > possible to approximate that metafunction in portable code.
>
> Wouldn't something about these lines work?
>
> template<typename T>
> char test( T const&, long );
>
> template<typename T>
> int test( std::list<T> const&, int );
>
> template<typename T>
> struct is_list
> {
> static T t;
> enum { value = sizeof( test( t, 0 ) ) == 4; }
> };
Thanks for the hint, but I think this would only detect lists - not other
sequence (vector, deque, possible user defined sequences).
In case someone is interested:
My original objective was to distinguish OutputIterators and Sequences.
So I settled for a solution that checks if the type has a nested type
"iterator". Of course, that does not suffice to establish a Sequence, but
for my application it is good enough...
Wolfgang Meyer
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