specialization of implicitly-declared special member function

Mark Mitchell mark@markmitchell.com
Thu Sep 10 18:18:00 GMT 1998


>>>>> "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



More information about the Gcc mailing list