Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | "Alf P. Steinbach"<alf.p.steinbach+usenet@gmail.com> |
| Newsgroups | comp.std.c++ |
| Subject | defect report: unique_ptr for array does not support cv qualification conversion of actual argument |
| Date | Fri, 16 Dec 2011 11:40:48 -0800 (PST) |
| Organization | A noiseless patient Spider |
| Lines | 66 |
| Sender | std-cpp-request@vandevoorde.com |
| Approved | stephen.clamage@oracle.com |
| Message-ID | <jcfabq$al2$1@dont-email.me> (permalink) |
| NNTP-Posting-Host | kpVS3B8zaLfmakQ0Z941e4/lcfrMU4MKX0VIAnnQTw4= |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| X-Trace | news.albasani.net WnaKL3gTNudrLFKhJJ+zufPeBaSqa5xpBVJ3DVJ6/tdt8B5YRg3NJgHHEbct+tw+Enz8cP1LmpszT6e9JPqeFg== |
| X-Complaints-To | abuse@albasani.net |
| NNTP-Posting-Date | Fri, 16 Dec 2011 19:40:49 +0000 (UTC) |
| X-Mailer | Perl5 Mail::Internet v2.05 |
| X-Submission-Address | std-cpp-submit@vandevoorde.com |
| Cancel-Lock | sha1:AdXOwODbZtPbMnsyKX+Nes1po1E= |
| X-Original-Date | Fri, 16 Dec 2011 12:34:15 +0100 |
| Xref | x330-a1.tempe.blueboxinc.net comp.std.c++:397 |
Show key headers only | View raw
N3290 §20.7.1.3.1 "unique_ptr constructors" [unique.ptr.runtime.ctor]:
"These constructors behave the same as in the primary template except
that they do not accept pointer types which are convertible to
`pointer`. [/Note:/ One implementation technique is to create private
templated overloads of these members. /—end note/]"
This language excludes even `pointer` itself as type for the actual
argument.
But of more practical concern is that both Visual C++ 10.0 and MinGW g++
4.1.1 reject the code below, where only an implicit cv qualification is
needed, which cv qualification is supported by the non-array version:
<code>
#include<memory>
using namespace std;
struct T {};
T* foo() { return new T; }
T const* bar() { return foo(); }
int main()
{
unique_ptr< T const> p1( bar() ); // OK
unique_ptr< T const []> a1( bar() ); // OK
unique_ptr< T const> p2( foo() ); // OK
unique_ptr< T const []> a2( foo() ); // ? this is line #15
}
</code>
The /intent/ seems to be clearly specified in §20.7.1.3/1 2nd dash:
"Pointers to types derived from T are rejected by the constructors,
and by reset."
But the following language in §20.7.1.3.1 then rejects far too much...
Proposed new wording of N3290 §20.7.1.3.1 "unique_ptr constructors"
[unique.ptr.runtime.ctor]:
"These constructors behave the same as in the primary template except
that actual argument pointers `p` to types derived from T are rejected
by the constructors. [/Note:/ One implementation technique is to create
private templated overloads of these members. /—end note/]"
This will possibly capture the intent better, and avoid the
inconsistency between the non-array and array versions of unique_ptr, by
using nearly the exact same phrasing as for the paragraph explaining the
intent.
Cheers,
- Alf
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next | Find similar
defect report: unique_ptr for array does not support cv qualification conversion of actual argument "Alf P. Steinbach"<alf.p.steinbach+usenet@gmail.com> - 2011-12-16 11:40 -0800
csiph-web