Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2004-08-27 19:00:46


On 8/25/04 11:05 AM, "Markus Schöpflin" <markus.schoepflin_at_[hidden]>
wrote:

> Currently, the name mangling scheme used on this platform is the default
> one selected by the compiler. It turns out that this is a bad choice when
> compiling boost. The problem is illustrated by the following example:
>
> ---%<---
> #include <iostream>
> using namespace std;
>
> template <typename T> void foo(T const &x)
> {
> cout << "1" << endl;
> }
>
> template <typename T> void foo(T * const &x)
> {
> cout << "2" << endl;
> }
>
> int main()
> {
> foo("abc");
> return 0;
> }
> --->%---
>
> This prints out "2" with the default name mangling scheme. When manually
> selecting "ansi" as the name mangling scheme, the correct result "1" is
> printed.

Why is [1] the correct answer? The string has type "char const [4]". I
thought that the array-to-pointer conversion will happen, turning the string
to a "char const *", which will match [2] with "char" for "T". I'm guessing
that you think the reference in [1] prevents the array-to-pointer
conversion, so [1] is the better match with "char [4]" for "T".

I am guessing your logic correctly? Does anyone know if [1] is supposed to
be the right answer? (No need to petition to change to compiler settings to
choose [1] if [2] is supposed to be the standard answer.)

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

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