473,804 Members | 3,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write an allocator for the STL List in VC++ 6.0

Hi,
there is a book from Andre Wilms describing how to write allocators
for STL containers. Unfortunately the MS VC++ Compiler is not
supporting the full ANSI standard in the template part of the C++
programming language. This is the reason why the implementation
proposal of Wilms is not working with this compiler.
Is there anyone who knows a implementation proposal for an allocator
working with VC++?

Thanks

Ralf Schneeweiß

http:/www.oop-trainer.de
Jul 19 '05 #1
2 4421
Ralf Schneeweiß wrote:

Hi,
there is a book from Andre Wilms describing how to write allocators
for STL containers. Unfortunately the MS VC++ Compiler is not
supporting the full ANSI standard in the template part of the C++
programming language. This is the reason why the implementation
proposal of Wilms is not working with this compiler.
Is there anyone who knows a implementation proposal for an allocator
working with VC++?


You need to provide a function named _Charalloc, because VC6 can't
handle the nested template that's used to rebind an allocator<T> to an
allocator<U>. Take a look at the VC++ header <xmemory> to see what
_Charalloc looks like.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 19 '05 #2
in**@oop-trainer.de (Ralf Schneeweiß) wrote in message news:<a6******* *************** ****@posting.go ogle.com>...
Hi,
there is a book from Andre Wilms describing how to write allocators
for STL containers. Unfortunately the MS VC++ Compiler is not
supporting the full ANSI standard in the template part of the C++
programming language. This is the reason why the implementation
proposal of Wilms is not working with this compiler.
Is there anyone who knows a implementation proposal for an allocator
working with VC++?


(a) This is an ISO C++ newsgroup; Visual C++ questions like this one
would best be directed to a Visual C++ newsgroup (e.g.,
comp.os.ms-windows.program mer.*).

(b) If you open the header file "memory" in your Visual C++ include
directory (e.g., c:\program files\microsoft visual
studio\vc98\inc lude), you will find that it refers to another header
("xmemory") in the same directory. In that file is defined the MSVC++6
allocator class. Just re-implement its interface.

- Shane
Jul 19 '05 #3

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

Similar topics

2
2491
by: madmanahong | last post by:
I Found new & delete of the CRT was very slow. so I overloaded the global new & delete operator. but if the CRT & STL also use my new & delete operator. It's bad because then my overloaded memory system didn't initialized. I also find the DLMalloc, but use 20 threads to call DLMalloc in a time, its wrong.
1
7298
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error: Creating library Release/fnimqcmd.lib and object Release/fnimqcmd.exp CoIMQCmd.obj : error LNK2001: unresolved external symbol
1
2805
by: xqxu.pzhou | last post by:
I wrote a simple allocator "myAlloc" under the g++ 3.2.3. When it is used by Vector, it works well. But when it is used by List, the codes have errors when compling. the error message is: "no matching function for call to myAlloc<std::_List_node<int> Then I added the following copy constructor to "myAlloc", now it works well. "template <typename U> myAlloc(const myAlloc<U>&) {}"
2
3932
by: ranin02 | last post by:
Hi, We have a list derived from std::list that has a custom allocator derived from std::allocator. This was originally written using VC++ 6.0 which required a workaround for the fact that 6.0 did not support nested templates classes, so could not use the rebind struct. Instead, a _Charalloc function was implemented. Now that we are moving to VS 2005, this is no longer working so I need to implement using the rebind struct. So I did...
3
4656
by: Mike | last post by:
Hi, I have a simple "memPool' class that simply maintains a linked list of chunks from which allocation requests are made. The whole thing is deleted all at once upon destruction. So far, so good. Then I tried to make an allocator for this and use it with std::list with no success. I modeled my allocator code from gcc's new_allocator.h. I modified the allocate() and deallocate() functions and copy constructors, and added a...
0
1175
by: Juha Nieminen | last post by:
I wrote this allocator which you can use with std::list, std::set and std::map (cannot be used with std::vector nor std::deque, but that doesn't matter because there would be no benefits with those). I have measured amazing speedups when using this allocator. For example I have made several speed tests using an std::list<intusing the default allocator and my allocator, adding and removing large amounts of elements from the list...
6
3389
by: Paavo Helde | last post by:
Juha Nieminen <nospam@thanks.invalidwrote in news:47f91b3c$0$8161 $4f793bc4@news.tdc.fi: I would guess that most speedup comes from the fact that the general allocator is thread-safe and yours is not (according to the web page), so you are comparing not quite the same things. Thread synchronization is quite expensive (and becomes relatively more expensive all the time with the number of processor cores growing). I think in the future...
6
13861
by: Juha Nieminen | last post by:
I tested the speed of a simple program like this: //------------------------------------------------------------ #include <list> #include <boost/pool/pool_alloc.hpp> int main() { typedef std::list<intList_t; // default allocator //typedef std::list<int, boost::pool_allocator<int List_t;
3
5899
by: maneshborase | last post by:
Hi friends, I am facing one serious problem in my application. I am trying to open dicom image file (.dcm) has size around 400 MB. But I am getting and unhandy exceptions, Some time, {System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at...
0
9704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
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,...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
agi2029
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...
1
7608
isladogs
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...
0
6844
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();...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.