Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-07-11 05:17:02

Jason Shirk wrote:
> Your second example gives an error with VC7 Beta2. If you get rid of
> the explicit specialization, then it compiles without error and
> generates correct code. I'm not sure if the error is a bug or not. I
> have several compilers that can't agree on explicit specializations
> defined inside a class.

In-class specializations of member templates are not allowed (see for the
details), so your compiler is correct here.

BTW, even if they were allowed, specializing a template assignment operator

template<typename U> A<T>& operator = (const A<U>& that);

for the case when U == T wouldn't make sense anyway, because such
specialization would never be called.

In fact, if you try to specialize it (in namespace scope) for a particular U
== T == int (for example; you can't specialize it for all U == T, even in
namespace scope), Comeau issues the following diagnostic:

template<> A<int>&
A<int>::operator=(const A<int>& that) {
  return *this;

[Comeau C/C++ for MS_WINDOWS_x86]
"E:\\depot\\libs\\msvc70.cpp", line 16: error #792:
          "A<int> &A<T>::operator=(const A<int> &) [with T=int]" is not an
          entity that can be explicitly specialized
  A<int>::operator=(const A<int>& that) {

Interesting, isn't it :)..


Boost list run by bdawes at, gregod at, cpdaniel at, john at