Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5224

Re: Overloading a template member function with a dependent name

From Ruben Safir <mrbrklyn@panix.com>
Newsgroups comp.lang.c++
Subject Re: Overloading a template member function with a dependent name
Date 2011-05-20 23:33 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <ir6tni$or$1@reader1.panix.com> (permalink)
References <1679ca72-2e81-4fb5-9e8c-ff2a89a7cfff@x38g2000pri.googlegroups.com>

Show all headers | View raw


mlimber <mlimber@gmail.com> wrote:
> I'm trying to overload a template member function with a dependent
> name involved. The following does not work as I'd like:
> 
> class C
> {
> public:
>   template<class Iter>
>   void Foo( Iter )
>   {
>     std::cout << "Normal\n";
>   }
> 
>   template<class T, std::size_t N>
>   void Foo( typename std::tr1::array<T,N>::iterator )
>   {
>     std::cout << "Special\n";
>   }
> };
> 
> int main()
> {
>   C c;
>   std::tr1::array<int,10> a1;
>   c.Foo( a1.begin() ); // Doesn't print "Special"!
> }
> 
> How can I get that last line in main() to invoke the special C::Foo()?

Foo is not in your class, and I'm actually surprise this compiles with
the keyword typename in the parameter list.

Ruben

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Overloading a template member function with a dependent name mlimber <mlimber@gmail.com> - 2011-05-20 13:37 -0700
  Re: Overloading a template member function with a dependent name mlimber <mlimber@gmail.com> - 2011-05-20 14:09 -0700
  Re: Overloading a template member function with a dependent name "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-05-20 23:21 +0200
    Re: Overloading a template member function with a dependent name mlimber <mlimber@gmail.com> - 2011-05-20 14:21 -0700
      Re: Overloading a template member function with a dependent name "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-05-21 01:30 +0200
  Re: Overloading a template member function with a dependent name Ruben Safir <mrbrklyn@panix.com> - 2011-05-20 23:33 +0000
    Re: Overloading a template member function with a dependent name "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-05-21 01:47 +0200

csiph-web