Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-04-15 09:28:21


> > > using namespace boost::numeric; // BEFORE
> > > #include "stats.hpp"

> > It shouldn't be needed. 'abs' is defined in the same namespace than
> > 'interval' so the name resolution should find the correct version of
> > 'abs'. Am I missing something here?

According to the standard, this is correct via Koenig lookup.

>It seems to be needed. I too suspect the MSVC 7.0 compiler. With luck 7.1
>will
>be better.

MSVC 7.0 only supports Koenig lookup for *operators*. This is why doing
things like overloading the << operator for streams works when defined in
the same namespace as the associated type.

I assume that they have fixed this in 7.1.

> > This code: > using boost::numeric::interval_lib::pi; > I a = pi<I>(); >
>works with GCC and Intel CC., but MSVC 7.0 says:

>typedef boost::numeric::interval<double> I;
>using boost::numeric::interval_lib::pi;
>a = pi<I>();

>testInterval.cpp(65) : error C2275: 'I' : illegal use of this type as an
>expression
> testInterval.cpp(59) : see declaration of 'I' testInterval.cpp(65)
>: error C2059: syntax error : ')'

I think this is because MSVC 7.0 does not properly support using templates.
That is, it has a problem deducing that pi is a template function, so treats
the '<' as a less than operator rather than a template operator.

>but

>I pi_d = boost::numeric::interval_lib::pi< boost::numeric::interval<double>
> >();
>I pi_d1 = boost::numeric::interval_lib::pi<I>();

>are OK,

These work because MSVC can locate the pi function and deduce that is a
template type.

>so am I in bad company in my (lack of) understanding of C++ :-(

-rhd-
mailto:msclrhd_at_[hidden]

_________________________________________________________________
Surf together with new Shared Browsing
http://join.msn.com/?page=features/browse&pgmarket=en-gb&XAPID=74&DI=1059


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