This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: specialization of implicitly-declared special member function


>>>>> "nbecker" ==   <nbecker@fred.net> writes:

    nbecker> Is this really an error?  (Where is a copy of the
    nbecker> standard available?)

    nbecker> template<class T> class A { public: template<class I> A
    nbecker> (const I& a, const I& b); template<> A (int a, int b); };

Yes, it's really an error, but the message was bad.  In current
versions of EGCS you get:

  test6.C:6: explicit specialization in non-namespace scope `A<T>'

which is the correct error.  You have to write something like:

  template<class T>
  class A {
  public:
    template<class I> A (const I& a, const I& b);
  };

  template<>
  template<> 
  A<int>::A(const int& a, const int& b)
  {
  }

Note that you cannot write:

  template <class T>
  template<> 
  A<T>::A(const int& a, const int& b)
  {
  }

This meets (correctly) with the error:

  test5.C:8: enclosing class templates are not explicitly specialized

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]