Boost logo

Boost :

Subject: Re: [boost] [Review] Type Traits Introspection library by Edward Diener starts tomorrow Friday 1
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-07-05 08:18:48


> On 7/4/2011 7:07 AM, John Maddock wrote:
>>> For Intel 11.1 or 12.0 can you tell me if the MPL tests pass,
>>> particularly just the test of has_xxx.cpp ? If that fails for MPL it
>>> fully explains why my tests for Intel are failing ( I am just reusing
>>> BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF internally ) and a workaround
>>> would need to be found in MPL.
>>
>> Ah: there are failures for mpl with Intel as well - results attached.
>
> Thanks !
>
> If you can, is it possible to get the preprocessor output decently
> formatted for Intel Linux 12.0 when it expands the macro
> BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF on line 20 of
> boost/libs/mpl/test/has_xxx.cpp ? There is no rush and if you find it is
> too much work, I will understand.

Reduced test case below compiles with VC++ and G++ but not Intel: I'll
report it to Intel later.

John.

template <bool b>
struct bool_
{
   static const bool value = b;
};

template< typename T > struct type_wrapper
{
    typedef T type;
};

template< typename T , typename fallback_ = bool_< false > >
class has_xxx_template
{
   template< typename U >
   struct has_xxx_template_introspect
   {
      template< template< typename V0 > class V >
      struct has_xxx_template_substitute0 { };
      template< template< typename V0 , typename V1 > class V >
      struct has_xxx_template_substitute1 { };
      template< template< typename V0 , typename V1 , typename V2 > class V
>
      struct has_xxx_template_substitute2 { };
      template< template< typename V0 , typename V1 , typename V2 ,
typename V3 > class V >
      struct has_xxx_template_substitute3 { };
      template< template< typename V0 , typename V1 , typename V2 ,
typename V3 , typename V4 > class V >
      struct has_xxx_template_substitute4 { };
      template< typename V >
      static char has_xxx_template_test(...);
      template< typename V >
      static double has_xxx_template_test( type_wrapper< V > const volatile*
, has_xxx_template_substitute0 < V::template xxx > * = 0 );
      template< typename V >
      static double has_xxx_template_test( type_wrapper< V > const volatile*
, has_xxx_template_substitute1 < V::template xxx > * = 0 );
      template< typename V >
      static double has_xxx_template_test( type_wrapper< V > const volatile*
, has_xxx_template_substitute2 < V::template xxx > * = 0 );
      template< typename V >
      static double has_xxx_template_test( type_wrapper< V > const volatile*
, has_xxx_template_substitute3 < V::template xxx > * = 0 );
      template< typename V >
      static double has_xxx_template_test( type_wrapper< V > const volatile*
, has_xxx_template_substitute4 < V::template xxx > * = 0 );
      static const bool value = sizeof(has_xxx_template_test< U >(0)) ==
sizeof(double);
      typedef bool_< value > type;
   };
public:
   static const bool value = has_xxx_template_introspect< T > ::value;
   typedef typename has_xxx_template_introspect< T > ::type type;
};

struct a5 { template< typename T > struct xxx {}; };

int main()
{
    typedef int a[has_xxx_template<a5>::value ? 1 : -1];
}


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