![]() |
Is there aA correct way of specializing member functions of template classes?
Suppose I have the following:
foo.h-- template <class T> class Foo { T bar(const T&); }; foo.cpp-- #include "foo.h" int Foo<int>::bar(const int& x) { .... return ...; } The compile fails with " error: too few template-parameter-lists" (g++ 4.5). Is there a correct way to properly specialize such member functions? As there is a small, finite set of T to be used, I want to specialize for all T. |
Re: Is there aA correct way of specializing member functions of template classes?
On Mon, 28 Feb 2011 21:30:14 -0800, m0shbear wrote:
> int Foo<int>::bar(const int& x) { > ... > return ...; > } > > The compile fails with " error: too few template-parameter-lists" (g++ > 4.5). > > Is there a correct way to properly specialize such member functions? template<> int Foo<int>::bar(const int& x) { |
Re: Is there aA correct way of specializing member functions of template classes?
"m0shbear" <andrey.vul@gmail.com> wrote in message news:a2443ccb-a350-44c2-bbd7-fc9eb41a988f@s18g2000vbe.googlegroups.com... > Suppose I have the following: > foo.h-- > template <class T> > class Foo { > T bar(const T&); > }; > > foo.cpp-- > #include "foo.h" > int Foo<int>::bar(const int& x) { > ... > return ...; > } > > The compile fails with " error: too few template-parameter-lists" (g++ > 4.5). > > Is there a correct way to properly specialize such member functions? > As there is a small, finite set of T to be used, I want to specialize > for all T. > AFAIK you cannot specialise the member function without specialising the whole class. .. |
| All times are GMT. The time now is 03:45 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.