Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-07-13 20:56:54


"David Abrahams" <dave_at_[hidden]> wrote in message
news:upt6z5s2f.fsf_at_boost-consulting.com...
> "Jonathan Turkanis" <technews_at_[hidden]> writes:

> >
> > I wouldn't count on any member detection with VC6. I little works
with
> > V7.0.
>
> You can detect type members on vc6. See mpl/aux_/has_xxx.hpp.

I'm familiar with the implementation of has_xxx, but I was pretty sure
it didn't work on VC6

....

In fact, the test program at the end of this message compiles fine on
VC6, but should static assert if has_xxx is supported. Am I doing
something wrong?

By the way, I have an implementation of has_template_xxx, which
detects member templates. It works on all my SFINAE-capable
compilers -- seven, at last count -- but I'm afraid it's probably not
standard-conforming. Any interest?

Jonathan

--------------------------------------------------------------------

    #include <boost/mpl/aux_/has_xxx.hpp>
    #include <boost/static_assert.hpp>

    struct S { };

    struct T {
        typedef int kids;
    };

    BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_kids, kids, true)

    int main()
    {
        BOOST_STATIC_ASSERT(has_kids<S>::value); // Should fail.
        BOOST_STATIC_ASSERT(has_kids<T>::value);
    }


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk