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 5 2030
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
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 automatical ly hide (global) placement new?
Yes, for that class only.
Would this prevent STL container classes from working (e.g., does std::allocato r 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
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.
"Dev" <de********@yah oo.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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
David White wrote: "Dev" <de********@yah oo.com> wrote in message news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Mark P wrote:
Would this prevent STL container classes from working (e.g., does std::allocat or 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 gcc 2.95.2. The gcc
version, I've installed on my computer, is 3.xx and I don't have the
source files of the libraries. Can I link those libraries without
uninstalling my new 3.xx-compiler?
Thanx for your answers in advance. Isn't there a secret...
|
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
advantages/disadvantages of using either?
Thanks!
|
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 objects, again allocated using "new".
From my tests I deduce that a considerable part of the computational
time is spent on the memory allocation, which makes the program
substantially slower compared to the equivalent code written using
|
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 a class called polynomial. Its a nothing little class right now,
with just int variables, a basic container class. Im using it as I go
through some tutorials, but in this particular tutorial its telling me to do
polynomial *first = new...
|
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 nessesary (at least to
me). What follows is an example taken from the FLTK tutorial:
-------------
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
| |
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 SimpleCompositor object.
|
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 since this "value" type is all set to
go. Is this because value types are stored on the stack so the memory
initialization is already taken care of?
Now, when dealing with an object type, it seems you do need to use the "new"
|
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 a function
|
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 the end of the app
for example:
class test
{
public:
int x;
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |