This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15674] New: template argument binding differs between member and static fumctions


#include <iostream>

int a[5];
int* p;

template<typename T>
class Foo {
public:
void S(T*) { std::cout << "found ref" << std::endl; }

template<size_t n>
void S(T(&a)[n]) { std::cout << "found array" << std::endl; }
};

template<typename T>
void S(T*) { std::cout << "found ref" << std::endl; }

template<typename T, size_t n>
void S(T(&a)[n]) { std::cout << "found array" << std::endl; }

int main() {
    Foo<int> s;
    s.S(a);
    s.S(p);
    S(a);
    S(p);
    return 0;
    }

When run, this produces:
~/ootbc/common/test/src$ a.out
found ref
found ref
found array
found ref

That is, the two calls to the member S both bind to the T* template, but for the global functions with identical signature one binds to each overload.

Ivan

-- 
           Summary: template argument binding differs between member and
                    static fumctions
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]