Topic: const qualifier for template dependent types?


Author: jon@floorboard.com (Jonathan Biggar)
Date: Fri, 7 Feb 2003 19:59:09 +0000 (UTC)
Raw View
The following code is rejected by gcc 3.2:

template <class A>
class T1 {
public:
    T1(const A a) { }
};

typedef char CA[2];

class T2 : public T1<CA> {
public:
    T2(const CA a) : T1<CA>(a) { }
};

% gcc test.cc
test.cc: In constructor `T2::T2(const char*)':
test.cc:11: invalid conversion from `const char*' to `char*'
test.cc:11:   initializing argument 1 of `T1<A>::T1(A) [with A =
char[2]]'

Apparently gcc doesn't think that the const qualifier should be
propagated to the element type of the array, as is the normal behavior
from 8.3.4, when the array is a template parameter and the const
qualifier is applied inside the template definition.

Is this correct behavior, and if so, can anybody point me to the
standard text to support it?

--
Jon Biggar
Floorboard Software
jon@floorboard.com
jon@biggar.org

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]