Mail Archives: djgpp/2001/11/28/09:20:21
From: | "Randy Maddox" <rmaddox AT isicns DOT com>
|
To: | <djgpp AT delorie DOT com>
|
Cc: | "Randy Maddox" <rmaddox AT isicns DOT com>
|
Subject: | Problem with template member of template class
|
Date: | Wed, 28 Nov 2001 09:16:49 -0500
|
Message-ID: | <000e01c17817$520a1d20$3502a8c0@nancy>
|
MIME-Version: | 1.0
|
X-Priority: | 3 (Normal)
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
|
Importance: | Normal
|
X-MS-TNEF-Correlator: | 000000009C48F545F726D442AB16EBB632D02A0D241A2000
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2919.6700
|
Reply-To: | djgpp AT delorie DOT com
|
This is a multi-part message in MIME format.
------=_NextPart_000_000F_01C177ED.69341520
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello,
I am using the WinDoze 2K version of DJGPP as found in the zip archive
djdev204_alpha_win2k.zip and have encountered an issue compiling a template
member of a template class. This works fine only so long as the template
member is both declared and defined in the class declarations. However, as
soon as I try to define the template member outside of the class
declarations I get a compile error. For example:
- This compiles fine and works as expected:
// test driver for template class template member
#include <iostream>
template <typename T1> class Test
{
public:
Test(const T1 & privateValue)
: privateValue_(privateValue)
{ }
template <typename T2>
void Write(const T2 & value)
{
std::cout << "Write() value is: " << value << std::endl;
std::cout << "privateValue is: " << privateValue_ << std::endl
<< std::endl;
}
private:
const T1 privateValue_;
};
int main()
{
std::cout << "Start of test driver" << std::endl << std::endl;
Test<double> test(3.3);
test.Write("string value");
test.Write(4);
std::cout << std::endl << "End of test driver" << std::endl;
}
// end of this file
However, if I try to move the definition of Write() outside of the class
declarations as shown here:
// test driver for template class template member
#include <iostream>
template <typename T1> class Test
{
public:
Test(const T1 & privateValue)
: privateValue_(privateValue)
{ }
template <typename T2>
void Write(const T2 & value);
private:
const T1 privateValue_;
};
template <typename T1>
template <typename T2>
void Test<T1>::Write<T2>(const T2 & value)
{
std::cout << "Write() value is: " << value << std::endl;
std::cout << "privateValue is: " << privateValue_ << std::endl
<< std::endl;
}
int main()
{
std::cout << "Start of test driver" << std::endl << std::endl;
Test<double> test(3.3);
test.Write("string value");
test.Write(4);
std::cout << std::endl << "End of test driver" << std::endl;
}
// end of this file
Then I get the following compile error:
>gxx test2.cpp
test2.cpp:25: partial specialization `Write<T2>' of function template
Since, as far as I can tell from the Standard, this looks like the correct
syntax why do I get this error? Is this a bug? An unsupported feature? Or
do I just not actually understand the syntax?
Using gxx -v reports the following:
>gxx -v
Reading specs from C:/djgpp/bin/../lib/gcc-lib/djgpp/3.02/specs
Configured with: ../configure i586-pc-msdosdjgpp --prefix=/dev/env/DJDIR
--disable-nls
Thread model: single
gcc version 3.0.2
C:/djgpp/bin/../lib/gcc-lib/djgpp/3.02/collect2.exe c:/djgpp/lib/crt0.o
-LC:/djgpp/bin/../lib/
gcc-lib/djgpp/3.02 -LC:/djgpp/bin/../lib/gcc-lib -Lc:/djgpp/lib
-Lc:/djgpp/lib/gcc-lib/djgpp/3.
02 -Lc:/djgpp/bin -Lc:/djgpp/lib
-LC:/djgpp/bin/../lib/gcc-lib/djgpp/3.02/../../.. -Lc:/djgpp/l
ib/gcc-lib/djgpp/3.02/../../.. -lstdcxx -lm -lgcc -lc -lgcc -Tdjgpp-x.djl
Thanks.
Randy Maddox
C++ Author, Architect, Developer
703-883-8088 ext. 119 (8 am to 4:30 pm Eastern USA time)
rmaddox AT isicns DOT com
------=_NextPart_000_000F_01C177ED.69341520
Content-Type: application/ms-tnef;
name="winmail.dat"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="winmail.dat"
eJ8+IjEOAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy
b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEGgAMADgAAANEHCwAcAAkAEAAAAAMAGwEB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