Mail Archives: djgpp/2001/12/14/08:30:08
This is a multi-part message in MIME format.
------=_NextPart_000_0004_01C18478.E96B4D70
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Sorry to have taken up your time with this one. The compiler might have
provided a more informative error message, and Stroustrup's example on page
350 of the special edition of "The C++ Programming Language" could have been
a little less confusing, but the Gnu folks were kind enough to point out the
error of my ways. The problem was incorrect syntax. There is no <T2> after
Write. A careful re-reading of section 14.5.2 of the Standard agrees with
this, and the modified code compiles and runs exactly as expected.
Again, I do apologize for wasting your time. This was a simple user-ability
problem. :-)
Randy Maddox.
> -----Original Message-----
> From: Randy Maddox [mailto:rmaddox AT isicns DOT com]
> Sent: Wednesday, November 28, 2001 9:17 AM
> To: djgpp AT delorie DOT com
> Cc: Randy Maddox
> Subject: Problem with template member of template class
>
> 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 -Wall 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 -Wall test2.cpp
> 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/cc1plus.exe -v -iprefix
> C:\djgpp\bin/../lib/gcc-lib/djg
> pp/3.02/ -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=2
> -D__MSDOS__ -D__GO32__ -D__uni
> x__ -D__MSDOS__ -D__GO32__ -D__unix__ -Asystem=msdos -Asystem=unix
> -D__NO_INLINE__ -D__STDC_HOS
> TED__=1 -Wall -remap -imacros
> C:/djgpp/bin/../lib/gcc-lib/djgpp/3.02/djgpp.ver -Acpu=i386 -Amac
> hine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i586__ -D__tune_pentium__
> -DMSDOS -DGO32 -Dunix t
> est2.cpp -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS
> -D__GXX_ABI_VERSION=100 -quiet -dumpbas
> e test2.cpp -Wall -version -o c:/djgpp/tmp\ccfUr607.s
> GNU CPP version 3.0.2 (cpplib) (80386, BSD syntax)
> GNU C++ version 3.0.2 (djgpp)
> compiled by GNU C version 3.0.2.
> ignoring nonexistent directory "C:/djgpp/djgpp/include"
> ignoring nonexistent directory "c:/djgpp/djgpp/include"
> #include "..." search starts here:
> #include <...> search starts here:
> C:/djgpp/lang/cxx-v3
> C:/djgpp/lang/cxx-v3/djgpp
> C:/djgpp/lang/cxx-v3/backward
> C:/djgpp/lib/gcc-lib/djgpp/3.02/include
> c:/djgpp/lang/cxx-v3
> c:/djgpp/lang/cxx-v3/djgpp
> c:/djgpp/lang/cxx-v3/backward
> c:/djgpp/lib/gcc-lib/djgpp/3.02/include
> c:/djgpp/include
> End of search list.
> test2.cpp:25: partial specialization `Write<T2>' of function template
>
> 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_0004_01C18478.E96B4D70
Content-Type: application/ms-tnef;
name="winmail.dat"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="winmail.dat"
eJ8+IiYNAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy
b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEGgAMADgAAANEHDAAOAAgAGAAAAAUAFwEB
A5AGAHQPAAAkAAAACwACAAEAAAALACMAAAAAAAMAJgAAAAAACwApAAAAAAADAC4AAAAAAAMANgAA
AAAAHgBwAAEAAAAvAAAAUHJvYmxlbSB3aXRoIHRlbXBsYXRlIG1lbWJlciBvZiB0ZW1wbGF0ZSBj
bGFzcwAAAgFxAAEAAAAbAAAAAcF4F00fpDYKYvoVRkOZQaJLktxwmAMiswAgAAIBHQwBAAAAGAAA
AFNNVFA6Uk1BRERPWEBJU0lDTlMuQ09NAAsAAQ4BAAAAQAAGDgDYPJeihMEBAgEKDgEAAAAYAAAA
AAAAAJxI9UX3JtRCqxbrtjLQ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