Conversion operator and new
Indiana Epilepsy and Child Neurology
BrainChild@Skyler.com
Tue Feb 11 20:28:00 GMT 2003
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/
More information about the Cygwin
mailing list