Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-03-28 15:53:51


on Fri Mar 28 2008, Steven Watanabe <watanabesj-AT-gmail.com> wrote:

> AMDG
>
> David Abrahams wrote:
>> on Fri Mar 28 2008, Steven Watanabe <watanabesj-AT-gmail.com> wrote:
>>
>>
>>> It can break today under certain conditions.
>>>
>>> http://lists.boost.org/boost-users/2006/11/23322.php
>>>
>>
>> I don't understand how that is a case of what I'm describing. It looks
>> like a simple instantiation failure.
>
> Yep. The problem turns out to be that ADL causes msvc to instantate
> all the template parameters recursively.

> The result is that any constructs
> involving templates that cannot be instantiated cannot safely appear
> in the interfaces of non-metafunction class templates.

Actually I think they can if you wrap them appropriately:

instead of

  foo<_1, _2>

you write:

  do_not_instantiate(foo<_1,_2>)

I don't think function types have associated namespaces, do they?

> This means that using MPL lambda expressions as a replacement for
> template template parameters for instance doesn't work in general.

Bleah, that's ugly.

>> In C++0x you won't even be able to
>> write
>>
>> typedef vector<foo(bar)> x;
>>
>> without getting an error.
>>
>
> And this is better than the possibility of obscure errors when
> the compiler unexpectedly instantiates vector<foo(bar)>

It's "better" as long as you're not trying to do the kinds of things we
do with MPL lambdas and related constructs like many of those that
appear in Proto.

-- 
Dave Abrahams
Boost Consulting
http://boost-consulting.com

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