473,385 Members | 1,492 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,385 software developers and data experts.

STL: malloc_alloc - omission of types

Hello,

I am an newbiew with respect to creating custom allocator. Currently,
we are in the process of creating a custom allocator. Going through
most of the example, we have one which requires to specify the type
while specifying the allocator:

Eg: vector<int, my_allocator<int> > foo;

I know that the default allocator malloc_alloc does not require the
type.

Eg: vector<int, malloc_alloc> foo;

I am wondering how it is implemented. Going through the STL source
(stl_alloc) does not help me much. Hope someone can clarify.

Regards,
Shoban Jayaraj
Jul 22 '05 #1
2 2176

"Shoban Jeyaraj" <sh***********@yahoo.com> wrote in message
news:7f**************************@posting.google.c om...
Hello,

I am an newbiew with respect to creating custom allocator. Currently,
we are in the process of creating a custom allocator. Going through
most of the example, we have one which requires to specify the type
while specifying the allocator:

Eg: vector<int, my_allocator<int> > foo;

I know that the default allocator malloc_alloc does not require the
type.
malloc_alloc is not the default allocator.
The default allocator is std::allocator<T> where T is the first template
parameter.

Eg: vector<int, malloc_alloc> foo;

I am wondering how it is implemented. Going through the STL source
(stl_alloc) does not help me much. Hope someone can clarify.
Where are you getting your "STL" source from?

Regards,
Shoban Jayaraj


P.S. I think it is highly unlikely that this is a good idea anyway.
Jul 22 '05 #2
Shoban Jeyaraj wrote:
I know that the default allocator malloc_alloc does not require the
type.


Are you, by chance, using a very old SGI STL implementation? You should
know that allocators changed a lot since that implementation was
written. That implementation, although still good and honorable, is now
far from "standard". In particular, SGI STL allowed the member function
allocate() to return a void* but the C++ standard now mandates that it
shall return a typed pointer. That's why malloc_alloc does not require a
type but conforming allocators do.

Alberto
Jul 22 '05 #3

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

Similar topics

11
by: Maxim Khesin | last post by:
Hi, being recently introduced to the joys of programming in a powerful dynamic language (go snake!) I periodically rethink which parts of C++ I still miss. One thing I really enjoy is the generics...
5
by: Ray Gardener | last post by:
Would templates be necessary if C++ had all numeric types inherit from a base "number" class and had all types inherit from a base "object" class? (Sorry if this has already been discussed to...
32
by: Severin Ecker | last post by:
hi! normally i would simply do the following: std::vector<Element> vec; void somefunc() { Element e; vec.push_back(e); }
13
by: Shailesh Humbad | last post by:
I wrote a short page as a quick reference to c++ integer data types. Any feedback welcome: http://www.somacon.com/blog/page11.php
12
by: Herby | last post by:
Hi, I am currently reviewing what is required to convert a current MFC, COM server application into a .NET application. The objective is to compile ultimately to clr/safe. So we are seeking a...
20
by: Andrew Roberts | last post by:
Any more info on this? Anyone know when it will be released?
6
by: Bart Simpson | last post by:
I am writing a shared object (Dll in Windows) and I am making extensive use of the STL. I am getting lots of warnings like this: ClassA.h(139): warning C4251: 'ClassA::indexarray' : class...
9
by: Ian | last post by:
I would like to port my class library written in standard C++ with STL to C++/CLI. Several of my classes inherit from std::vector or std::deque. From what I can see, dot.net does not offer...
9
by: OuaisBla | last post by:
Although STL container can't support object by reference as a template argument. To make thing worse, allocator can't support stack based allocation. So: std::deque<std::string const &> is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.