Subject: Re: [boost] [mpl] BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
From: Edward Diener (eldiener_at_[hidden])
Date: 2010-07-18 19:11:45


On 7/18/2010 12:26 PM, Steven Watanabe wrote:
> AMDG
>
> Edward Diener wrote:
>> I found the BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF macro in the latest
>> has_xxx.hpp of mpl on the trunk.
>>
>> Is BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF ( and its corresponding
>> BOOST_MPL_HAS_XXX_TEMPLATE_DEF ) scheduled to be added to Boost in an
>> upcoming release ? I find it useful for TMP introspection in much the
>> same way as BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF ( and its corresponding
>> BOOST_MPL_HAS_XXX_TRAIT_DEF ).
>
> It's currently in the release branch and should be released in 1.44.

That is good to hear but...

My testing with VC9 and VC10 shows that if I pass too many tempate
arguments I get a compiler failure:

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

#include <boost/mpl/has_xxx.hpp>

struct AAType
   {
   template <class X> struct AAMemberTemplate { };
   };

BOOST_MPL_HAS_XXX_TEMPLATE_DEF(AAMemberTemplate)

has_AAMemberTemplate<AAType,int,int> yz; // error

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

error C2977: 'has_AAMemberTemplate' : too many template arguments
see declaration of 'has_AAMemberTemplate'
error C2133: 'yz' : unknown size
error C2512: 'has_AAMemberTemplate' : no appropriate default constructor
available

etc.

Of course I expect a BOOST_MPL_ASSERT failure for:

BOOST_MPL_ASSERT((has_AAMemberTemplate<AAType,int,int>)) but not a
compiler error.

The Concept Traits Library also had a macro which worked similarly, but
also failed for the same reason. When I discovered the implementation in
the trunk version of MPL I had hopes that this was better. Sigh !

The code in the MPL is highly complicated, else I would spend the hours
trying to understand it and perhaps fix it. But I hope that at least
reporting my failure with VC9 and VC10 will help to get this working.