public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13809] New: Template conversion operator reports ambiguity where none exists
@ 2004-01-22  5:49 gianni at mariani dot ws
  2004-01-22  8:29 ` [Bug c++/13809] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gianni at mariani dot ws @ 2004-01-22  5:49 UTC (permalink / raw)
  To: gcc-bugs

The code below compiles fine on Comeau and VC++ 7.1.

Error:

t29x.cpp: In function `int main()':
t29x.cpp:33: error: conversion from `X' to `std::set<int, std::less<int>,
   std::allocator<int> >' is ambiguous
t29x.cpp:9: error: candidates are: X::operator C<T, A>() [with T = int, A =
   std::less<int>, C = std::set]
t29x.cpp:15: error:                 X::operator C<T, A, B>() [with T = int, A =
   std::less<int>, B = std::allocator<int>, C = std::set]

Note that std::set is a 4 parameter template yet the ambiguity is reported on 2
and 3 parameters.  It appears the wrong logic is being used to deduce which
conversion operator to use.

So here's the code:

struct X
{
    struct C; //uncomment to make this work - see bug:13808

    template<typename T, typename A, template<typename,typename> class C>
        operator C<T, A > ()
    {
        return C<T, A>();
    }

    template<typename T, typename A, typename B,
template<typename,typename,typename> class C >
    operator C<T, A, B> ()
    {
        return C<T, A, B>();
    }

    template<typename T, typename A, typename B, typename Z,
template<typename,typename,typename,typename> class C >
    operator C<T, A, B, Z> ()
    {
        return C<T, A, B, Z>();
    }

};

#include <set>

int main()
{
    X   x;

    std::set<int>    s = x;
}

-- 
           Summary: Template conversion operator reports ambiguity where
                    none exists
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gianni at mariani dot ws
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13809


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-25 17:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-22  5:49 [Bug c++/13809] New: Template conversion operator reports ambiguity where none exists gianni at mariani dot ws
2004-01-22  8:29 ` [Bug c++/13809] " pinskia at gcc dot gnu dot org
2004-01-22  8:37 ` gianni at mariani dot ws
2004-01-22  8:45 ` pinskia at gcc dot gnu dot org
2004-01-23 18:55 ` gianni at mariani dot ws
2004-01-25 17:02 ` giovannibajo at libero dot it

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).