"Gennadiy Rozental" <[EMAIL PROTECTED]> writes:

> Hi,
>
> I am having problems with subject test with Metrowerks compiler. I was able
> to minimize the issue to the following snippet:
> #include <list>
> #include <iostream>
>
> template<typename T>
> inline void
> print( std::ostream& ostr, T const& t, long ) { ostr << t; }
>
> template<typename T>
> inline void
> moo( std::ostream& ostr, T const& t ) { print( ostr, t, 0 ); }
>
> inline void
> print( std::ostream& ostr, std::list<int> const& t, int ) {}
>
> void foo()
> {
>     std::list<int> lst;
>
>     print( std::cout, lst, 0 );  //1
>     moo( std::cout, lst );      //2
> }
>
> Line 1 compile successfully, while line 2 chokes.
>
> Any Ideas?

Please always post the error message you get when reporting such a
bug.

### mwcc Compiler:
#    File: foo.cpp
# ----------------
#       6:  print( ostream & ostr, T const & t, long ) { ostr << t; }
#   Error:                                           ^
#   illegal operands 'ostream' << 'const list<int>'
#    (point of instantiation: 'main()')
#     (instantiating: 'print<list<int> >(ostream &, const list<int> &, long)')


line 1 chooses the 2nd overload for print via partial ordering, but
line2 chooses the 1st overload due to something having to do with
2-phase name lookup, since on only the overloads visible at the point
of definition seem to be eligible.  That contradicts my understanding
of 2-phase lookup, because print is clearly a dependent name, but
Comeau online agrees with Metrowerks here.  Maybe someone else can
fill in the rest of the details.

> Gennadiy.
>
> P.S. Rest of Windows compilers I have access to seems to be happy with
> above.

None of them implement 2-phase lookup.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to