[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Q about g++-3 and template instantiation

Ilya, thanks VERY MUCH.  This solved my problem in a flash.  My
application (38 thousand lines, compared to the 6 lines of my
test-file) now compiles and links properly in g++-3, and, with a
preprocessor switch, in g++-2 as well.  In case other folks are
interested, below is how I now do it (sorry that I test for __GNUC__;
this code is meant to work for many other compilers as well) ...

  #if defined(__GNUC__)

  #if __GNUC__ == 3

  std::reverse(std::vector<double>::iterator, std::vector<double>::iterator);


  template void
  std::reverse(std::vector<double>::iterator, std::vector<double>::iterator);



Thanks very much for the help, delivered so quickly!!


On 3 May 2001, Ilya Martynov wrote:

> Date: 03 May 2001 17:50:45 +0400
> From: Ilya Martynov <m_ilya@agava.com>
> To: Dan Kelley <Dan.Kelley@Dal.Ca>
> Cc: debian-devel@lists.debian.org
> Subject: Re: Q about g++-3 and template instantiation
> DEK> Attached is a 6-line C++ test program (which does nothing more than
> DEK> instantiate templates) that compiles in g++-2, with
> DEK>         g++ -c test-template.cc
> DEK> but for which g++-3 yields the error messages:
> DEK>         test-template.cc:4: non-template used as template
> DEK>         test-template.cc:6: non-template used as template
> DEK> QUESTION: am I doing something wrong?
> As I understand you want to define specialization of template
> function? (I hope I chosed right English words). Specialization of
> template function is no longer template - it is function. So you
> should not use 'template' keyword. Just remove it.

Dan E. Kelley                                     phone:(902)494-1694
Oceanography Department, Dalhousie University       fax:(902)494-2885
Halifax, Nova Scotia                         mailto:Dan.Kelley@Dal.CA
Canada B3H 4J1   http://www.phys.ocean.dal.ca/~kelley/Kelley_Dan.html

Reply to: