Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-01-12 21:30:45


Gennaro Prota <gennaro_prota_at_[hidden]> writes:

> On Sun, 12 Jan 2003 17:34:51 -0500, David Abrahams
> <dave_at_[hidden]> wrote:
>
>>The latter. It was just an experiment. Fortunately, nothing I'm
>>doing depends very much on it. It was prompted by the fact that
>>Borland 5.51 can handle enable_if, but not in a templated constructor:
>>
>>template <class T>
>>struct X
>>{
>> template <class U>
>> X(X<U> const&, typename enable_if<some_property_of<U>::value, int*>::type = 0);
>>}
>>
>>The parser chokes on the first '<' inside the parens.
>
> Dave, just a quick remark before I really go to bed (it's late night
> here). I suspect that, even if you get rid of the parsing error,

I won't because I can't.

> Borland will give you problems when matching X's constructor.

I doubt it; it works without the enable_if clause.

> Anyhow, I would give it a try. From what I've seen, using that
> compiler occasionally, these sorts of parser bugs depends a lot on
> a) what the compiler 'knows' about the names that appear in the
> declaration (for instance it may choke at different points depending
> on whether you have a declaration of enable_if before the definition
> of X or not) and, fortunately, on b) parentheses. I wouldn't be
> surprised if the above compiled by simply putting the expression
>
> some_property_of<U>::value
>
> in parentheses. But I don't have your full code so I can't say.

No dice.

cd $BOOST_SANDBOX/libs/iterator/test
bjam -sTOOLS=borland test

if you want to try it. Edit out the line which defines
BOOST_NO_ENABLE_IF_CONSTRUCTORS in
$BOOST_SANDBOX/boost/iterator/iterator_adaptors.hpp

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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