473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Out-of-line template function

Hi,

I'm trying to get a member template of a template class defined
out-of-line. I'm failing miserably, though. Is this even possible ?

template <typename T>
struct foo
{
// Declare member template
template <typename U>
void bar(U);
};

// Define member template
template <typename T, typename U>
void foo<T>::bar(U)
{
}

VC.NET gives me:

ref.cpp(13) : error C2244: 'bar' : unable to match function definition
to an existing declaration
definition
'void foo<T>::bar(T2)'
existing declarations
'void foo<T>::bar(U)'

GCC says:

Line 10: error: prototype for `void foo::bar(U)' does
not match any in class `foo'
Line 5: error: candidate is: template
template void foo::bar(U)
Line 10: error: template definition of non-template `
void foo::bar(U)'
Any insights are appreciated,

Jaap
Nov 26 '05 #1
1 3288
Jaap wrote:
Hi,

I'm trying to get a member template of a template class defined
out-of-line. I'm failing miserably, though. Is this even possible ?

template <typename T>
struct foo
{
// Declare member template
template <typename U>
void bar(U);
};

// Define member template
template <typename T, typename U>
void foo<T>::bar(U)
{
}

[snip]


Any insights are appreciated,

Jaap


template <typename T>
template <typename U>
void foo<T>::bar(U)
{
}

john
Nov 26 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: FilexBB | last post by:
Hi Folks, I have tried to redirect system.out for a while and then set it back, but it can't set it back as following program snapshot ByteArrayOutputStream baos = new ByteArrayOutputStream();...
4
by: Merlin | last post by:
Hi there, I would like to check if a string is a valid zip code via Javascript. Length and existents are already checked. How can I find out if the string contains characters other than...
5
by: Mike Carroll | last post by:
I have a COM server that's generally working ok. But one of its methods, when the IDL gets read by the Intertop layer, has parameters of type "out object". The C# compiler tells me that it...
4
by: Steve B. | last post by:
Hello I'm wondering what is exactly the difference between "ref" and "out" keywords. Thanks, Steve
2
by: Chua Wen Ching | last post by:
Hi there, I am wondering the difference between attribute and out keywords. Are they the same or does it serve any different purposes? I saw the and out usage in this code, and i had idea,...
4
by: Jon | last post by:
Why are out parmeters included in an BeginInvoke? They seem to do nothing? TestProgam: using System; namespace TempConsole { class App { public delegate void MyDelegate( out byte b, out...
14
by: stic | last post by:
Hi, I'm in a middle of writing something like 'exception handler wraper' for a set of different methodes. The case is that I have ca. 40 methods form web servicem, with different return values...
4
by: dlgproc | last post by:
I have a managed C++ DLL that contains the following: MyLib.h: // MyLib.h #pragma once using namespace System; using namespace System::Runtime::InteropServices; namespace MyLib { public...
6
by: nick | last post by:
For example: public static void FillRow(Object obj, out SqlDateTime timeWritten, out SqlChars message, out SqlChars category, out long instanceId)
6
by: carlos123 | last post by:
Ok guys, check this out! Im getting an error "Error: Index: 0, Size: 0" not sure why. try{ // Create file FileWriter fstream = new FileWriter("database.txt"); BufferedWriter...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.