473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

a simpler "new" question

I think my previous posts on this subject are too verbose and are
scaring off replies so I'll keep this one brief:

If I define my own operator new(size_t size) in a class, does that
automatically hide (global) placement new?

Would this prevent STL container classes from working (e.g., does
std::allocator require placement new for its construct() method?)?

Thanks for your help,
Mark
Jul 23 '05 #1
5 2010
Mark P wrote:
I think my previous posts on this subject are too verbose and are
scaring off replies so I'll keep this one brief:

If I define my own operator new(size_t size) in a class, does that
automatically hide (global) placement new?
Yes, for that class only.
Would this prevent STL container classes from working (e.g., does
std::allocator require placement new for its construct() method?)?


That I am not sure of.

V
Jul 23 '05 #2
Victor Bazarov wrote:
Mark P wrote:
I think my previous posts on this subject are too verbose and are
scaring off replies so I'll keep this one brief:

If I define my own operator new(size_t size) in a class, does that
automatically hide (global) placement new?

Yes, for that class only.

Would this prevent STL container classes from working (e.g., does
std::allocator require placement new for its construct() method?)?

That I am not sure of.


I'd think, without checking, that std::allocator should call
global placement new... but I'll check...

And it's as well I did. It's apparently required to have the
same effect as:

new((void *)p) T(val)

which would not call global new if your class has an operator
new declared for it.

-- James
Jul 23 '05 #3
Dev
Mark P wrote:
I think my previous posts on this subject are too verbose and are
scaring off replies so I'll keep this one brief: If I define my own operator new(size_t size) in a class, does that
automatically hide (global) placement new?
Yes, It will hide only for the class in which you have defined new.

Would this prevent STL container classes from working (e.g., does
std::allocator require placement new for its construct() method?)?


No.

Jul 23 '05 #4
"Dev" <de********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Mark P wrote:
Would this prevent STL container classes from working (e.g., does
std::allocator require placement new for its construct() method?)?


No.


Well, std::vector<C> with VS .NET 2003 won't compile if class C does not
also provide placement new.

DW
Jul 23 '05 #5
David White wrote:
"Dev" <de********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Mark P wrote:
Would this prevent STL container classes from working (e.g., does
std::allocator require placement new for its construct() method?)?


No.

Well, std::vector<C> with VS .NET 2003 won't compile if class C does not
also provide placement new.

DW


As noted in my previous post, std::allocator::create is
required to use placement new.

-- James
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Philipp | last post by:
Hi, I am quite sure this question has answered here already several times, but I haven't found the answer yet. Anyway, here is the question again: I've got libraries (*.so) that are built with...
16
by: garyolsen | last post by:
For a class, MyClass, there are two ways to instantiate an object: 1. MyClass *MC = new MyClass(); 2. MyClass MC; In general, when should you have to use 1 and when 2? What're...
18
by: Leslaw Bieniasz | last post by:
Cracow, 28.10.2004 Hello, I have a program that intensively allocates and deletes lots of relatively small objects, using "new" operator. The objects themselves are composed of smaller...
24
by: Rv5 | last post by:
Rookie c++ question, but Ive spent the last 5 years doing Java, where everytime I created an object I used new. In c++ I can create my objects without and its confusing me just a little. I have...
1
by: sven_c_t | last post by:
Hi! Probably a newbie question. I´ve been working a bit with the widget toolkit FLTK and I have been wondering why there is such a heavy use of the new operator, when it does not seem to be...
2
by: PengYu.UT | last post by:
Hi, I saw the following code: Composition *quick = new Composition(new SimpleCompositor); SimpleCompositor and Composition are both classes. My question is how to delete the newed...
4
by: Ben R. | last post by:
I'm curious about the differeng behavior of the "new" keyword when dealing with value versus object types. If I'm correct, when I do: dim x as integer There's no need for "new" to be called...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
30
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.