public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Frank Winter <frank.winter@desy.de>
To: gcc-help@gcc.gnu.org
Subject: Avoid typename repetition in template specialization
Date: Fri, 09 Apr 2010 13:16:00 -0000	[thread overview]
Message-ID: <alpine.LRH.2.00.1004091503370.15744@pub1.ifh.de> (raw)

Dear all,

suppose a templated class:

template< typename T >
struct A {
 	const T& some_function( const T& )
 	T i[10];
};

and a specialization for some type, say
PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns >:

template<>
struct A<PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns > > {
 	const PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns >& 
some_function( const PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns 
>& )
 	PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns > i[10];
};

Is there a way to avoid the redundant typing of the specialized typename 
in the template specialization?

I know, using templates would exactly avoid this. But I really need 
this kind of specialization to specialize the some_function

I would not like to use the preprocessor. Like:

#define PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns > T
template<>
struct A<T> {
 	public:
 	const T& some_function( const T& )
 	T i[10];
}
#undef T


Isn't there a template-way of doing this?


Best regards,
Frank Winter


--

Institut fuer theoretische Physik
Universitaet Regensburg
Universitaetsstr. 31
93053 Regensburg
Germany

office +49 (0)941 943 2085

             reply	other threads:[~2010-04-09 13:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09 13:16 Frank Winter [this message]
2010-04-09 13:42 ` Axel Freyn
2010-04-09 13:57 Frank Winter
2010-04-09 14:11 ` John (Eljay) Love-Jensen
2010-04-10 12:51   ` Axel Freyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.00.1004091503370.15744@pub1.ifh.de \
    --to=frank.winter@desy.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).