Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2000-10-12 20:05:30


on 10/12/00 2:20 PM, Beman Dawes at beman_at_[hidden] wrote:

> ***** random/random_test.cpp *****
> Metrowerks CodeWarrior
> mwcc -maxerrors 10 -cwd source -I- -Ic:/boost/site
> c:/boost/site/libs/random/random_test.cpp
> ### mwcc Compiler:
> # In: ..\site\boost\random.hpp
> # From: ..\site\libs\random\random_test.cpp
> # --------------------------------------------
> # 147: return (a*x+c) % m;
> # Warning: ^
> # division by 0
> # (instantiating: 'boost::random::const_mod<unsigned long,
> # 0>::mult_add(unsigned long, unsigned long, unsigned long)')

Perhaps a mistake in the compiler, but can probably be worked around with
partial specialization.

> ### mwcc Compiler:
> # File: ..\site\libs\random\random_test.cpp
> # --------------------------------------------
> # 177: rand48 rnd(5);
> # Error: ^
> # ambiguous access to overloaded function
> # 'boost::rand48::rand48(unsigned long long)'
> # 'boost::rand48::rand48(long)'

Changing the constant to 5L should fix this.

> ### mwcc Compiler:
> # 179: rnd.seed(17);
> # Error: ^
> # ambiguous access to overloaded function
> # 'boost::rand48::seed(unsigned long long)'
> # 'boost::rand48::seed(long)'

Changing the constant to 17L should fix this.

> ***** utility/compressed_pair_test.cpp *****
> Metrowerks CodeWarrior
> mwcc -maxerrors 10 -cwd source -I- -Ic:/boost/site
> c:/boost/site/libs/utility/compressed_pair_test.cpp
> ### mwcc Compiler:
> # File: ..\site\libs\utility\compressed_pair_test.cpp
> # ------------------------------------------------------
> # 134: template double& compressed_pair<double, int&>::first();
> # Error: ^
> # illegal explicit template instantiation
> ### mwcc Compiler:
> # 135: template int& compressed_pair<double, int&>::second();
> # Error: ^
> # illegal explicit template instantiation
> ### mwcc Compiler:
> # 136: template compressed_pair<double, int&>::compressed_pair(int&);
> # Error: ^^^^^^^^^^^^^^^
> # declaration syntax error
> ### mwcc Compiler:
> # 137: template compressed_pair<double,
> int&>::compressed_pair(call_traits<double>::param_type,int&);
> # Error: ^^^^^^^^^^^^^^^
> # declaration syntax error

You can explicitly instantiate a template class, or a template member
function, but not a non-template member function of a template class (see
section 14.7.2 of the standard). The correct code here would be:

    template class Metrowerks::compressed_pair<double, int&>;

These attempts to instantiate individual member functions may work in some
compilers, but they are non-standard.

    -- Darin


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