From 2718919140546592820
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,297e1191220ad2df,start
X-Google-Attributes: gidf78e5,public
From: "Gabor Greif" <gabor@no.netopia.com>
Subject: [Q] function member template in a template class
Date: 1999/05/04
Message-ID: <B3539C4C-1E8FDD@192.168.1.8>#1/1
X-Deja-AN: 473881780
Content-Transfer-Encoding: 7bit
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
X-Original-Date: 3 May 99 18:32:40 +0200
Content-Type: text/plain; charset=US-ASCII
X-Newsgroups-TO: nntp://news.noris.de/comp.std.c++
Organization: noris network GmbH, Nuernberg, Germany
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUANy7eA6wEuYhIxRhxAQE+6gIAlD82hVgntZUY5DGTtVxWFnEmiVK7fFzt nJe5aIdfoSmRAVxIy7yc0fn0QrrBuFNZPr0Yy0ZHtpAj8DZGNHSbvA== =cykI
X-News-Servers: news.noris.de
Mime-Version: 1.0
Newsgroups: comp.std.c++

{ to moderator: I have posted this days ago, did not seem to have made it.
Nothing on dejanews. Did not got a rejection either... So I repost. }

Here is a question I was not able to answer myself yesterday night...

Suppose having a class template with two parameters and a function member
template in it (returning a two-parameter dependent result):

template <int I, typename T>
struct Res { };


template <int I, typename T>
struct Bar
{
	template <int J>
	typename Res<J, T> foo(void);
};

What is the syntax for defining the function foo outside of the Bar
template?

My attempt was 

template <int I, int J, typename T>
typename Res<J, T> Bar<I, T>::foo<J>(void)
{
	return Res<J, T>();
}


But my compiler rejected it.

Another tricky question:
Assuming I want to define foo for a special case that I == J. Is this
syntax correct?

template <int I, typename T>
typename Res<I, T> Bar<I, T>::foo<I>(void)
{
	return Res<I, T>();
}

But this also busts my compiler.

Can the standards gurus help me in this one?

Thanks in advance...

	Gabor
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



