Boost logo

Boost :

From: Mårten Rånge (marten.range_at_[hidden])
Date: 2005-01-04 11:05:18


I’m looking for a portable version of __if_exists (VS.NET keyword) and
unfortunately google turned up nothing good.

I use boost fairly regular and checked boost::type_traits but found nothing
that seemed to similar.

Has anyone heard of something that can accomplish this?

As a side note, I got inspired by the technique used when to enable/disable
template class specializations using boost::enable_if and succeeded in
creating something that managed this:

struct x
{
   typedef std::string aggregated_type;
};

struct y
{
};

int main(int, char*)
{
    std::cout << is_aggregated_type_available<x>::value << std::endl;
    std::cout << is_aggregated_type_available<y>::value << std::endl;
}

Prints:
1
0

Which means that x has an aggregated type named aggregated_type.

Unfortunately I failed miserably when trying to test for member variables
and member functions.

So I thought I take my chance and post my question here.

Regards,

Mårten Rånge

PS. I want to give a big thank-you to the boost community for putting 1.32.0
together. It was worth waiting for.

PS. I attached is_aggregated_type_available in case anyone is interested.
Unfortunately only tested on VS.NET 2003 and VS.NET 2005 Beta 1 but it feels
like it should work on more compilers due to the similarities with the
examples in boost::enable_if documentation.




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