Boost logo

Boost :

From: boost_at_[hidden]
Date: 2004-02-13 18:30:14


At 21:53 13/02/2004, you wrote:

>Mat Marcus wrote:

<snip>

>(while compiling monad3.cpp)
>monad3.cpp:82: error: no type named `second_type' in `struct
>OutputMonad<std::string>'
>This is a template shadow parameter issue, related to the fact that
>OutputMonad<> defines an inner type called "M", but a template member
>functions
>uses M as template parameter as well:
>
>struct A {
> typedef int M;
>
> template <class M> //*
> void foo(void) {
> M m; // which M is this?
> }
>};
>
>I know the C++ committe is discussing this issue at this moment. The argument
>would be that "M" names the typedef because it's "more stable" than the
>template parameter (which could get renamed in an out-of-class
>definition). See
>also http://gcc.gnu.org/PR13967 for a detailed discussion. It's possible that
>GCC will emit a warning about this borderline case of shadowing, one day. This
>is worked around easily, by renaming the innest template parameter, in
>line 107
>and 110, and all its subsequent uses.

I can't believe that???

So for

int i = 12;
{
         int i = 123; //*
         std::cout << i;
}

should I expect an output of 12 because the other i is more stable?

Maybe I'm wrong, but it seems stupid to have one rule for one case, and a
different rule for the effectively the same case.

The sensible opinion seems that the lines marked //* take precedence,
albeit ideally with a warning.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.573 / Virus Database: 363 - Release Date: 28/01/2004

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