This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
deprecated attributes vs. class templates
- From: "Benjamin Kosnik" <bkoz at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: "Jason Merrill" <jason at redhat dot com>
- Date: Thu, 17 May 2007 17:27:06 +0200
- Subject: deprecated attributes vs. class templates
Hey! I'm trying to figure out how to mark up std::auto_ptr as
deprecated when in C++0x mode.
From:
http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax
and
http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html#Type-Attributes
I gather that this attribute may work for C++. However, all my
attempted spell-casting to make use of this fail:
// no warning, but doesn't work
template<typename _Tp>
struct __attribute__ ((deprecated)) auto_ptr;
// warns ignored
template<typename _Tp>
__attribute__ ((deprecated)) struct auto_ptr;
// warns ignored
template<typename _Tp>
struct auto_ptr __attribute__ ((deprecated)) ;
And similar for the various placements around the definition.
I would assume that this means that the deprecated attribute doesn't
work in C++ mode, but then:
template<typename _Tp>
struct auto_ptr
{
private:
_Tp* _M_ptr;
};
int main()
{
typedef auto_ptr<int> test_type;
typedef auto_ptr<short> test2_type __attribute__ ((deprecated));
test_type obj;
test2_type obj2;
return 0;
}
gets me where I want to go, or at least partially where I want to go:
test2_type gets the deprecated warning.
So, now I'm wondering what I can expect, if I've not got the correct
syntax, or if this doesn't work (hasn't ever) and thus I should file a
feature-request/enhancement for this functionality. Something like
this will be necessary as many of the C++0x deprecated features are
mixed within existing includes, which make the previous strategy of
just warning on a per-file basis impossible.
Help!
best,
benjamin