Boost logo

Boost :

Subject: Re: [boost] [mpl] BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-07-18 20:02:36


On Sun, Jul 18, 2010 at 7:11 PM, Edward Diener <eldiener_at_[hidden]> wrote:
> 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:

Do an svn update on your local copy of trunk. You no longer need to
pass arguments to detect member templates. This change was checked in
a couple of weeks ago, so you might not have gotten it yet. See the
updated documentation.

>
> ----------------------------------------------------
>
> #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

After updating from svn, change the line to
has_AAMemberTemplate<AAType> yz;

You should no longer see an error. You can detect member templets with
any number of arguments up to the configurable
BOOST_MPL_LIMIT_METAFUNCTION_ARITY, which defaults to 5.

<snip>
> 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.

Thanks for reporting! Actually, when I ran your example code I noticed
a header dependency in boost/mpl/has_xxx.hpp that I had accidentally
missed. So, your report has helped improve things already.

Daniel Walker


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