This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Conversion operator and new
- From: Indiana Epilepsy and Child Neurology <BrainChild at Skyler dot com>
- To: cygwin at cygwin dot com
- Date: Tue, 11 Feb 2003 15:16:59 -0500
- Subject: Conversion operator and new
- Reply-to: BrainChild at Skyler dot com
Greetings!
g++ produces an error "size in array new must have integral type" in
function f2. I expected the conversion operators to convert x to
size_t, which is an integral type. They do if I remove *either* the
const *or* the non-const version of operator size_t, and they do for
passing x to function f1 in any case.
Is this a bug?
#include <cstddef>
struct X
{
operator size_t () { return
2; }
operator size_t () const { return 3; }
};
char *f1 ( size_t n ) { return
new char[n]; }
char *f2 ( const X &x ) { return new
char[x]; }
int main (void) { }
/*
$ g t.cpp -ot
t.cpp: In function `char* f2(const X&)':
t.cpp:11: size in array new must have integral type
*/
--
Don Stauffer, Office Manager
Indiana Epilepsy and Child Neurology, Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/