You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Susantha Kumara <su...@opensource.lk> on 2004/05/06 05:29:30 UTC

STL elimination - Suggestions

Hi all,
 
I would suggest following order and steps to gradually eliminate STL in
Axis C++ codebase.
 
std::string
1.	Use "char*" instead of "string" wherever possible - need to take
care of the memory allocation and deallocation
2.	Write our own String class to replace the strings left after
step 1.
std::map
1.	Review the code base and minimize the use of std::map's
functions. Replace std::map with arrays or lists where possible
2.	Write our own Map class with minimum functionality and use it in
yet existing places after step 1. Even if we don't use templates to
write this map class we can make this almost generic if we use a class
which has 
a.	void* for key
b.	void* for value
c.	allocator/deallocator provided externally
d.	key comparison function provided externally
 
std::queue
std::list
std::stack
1.	Probably we can use linked lists to replace these.
 
 
---
Susantha.

Re: STL elimination - Suggestions

Posted by Kenneth Chiu <ch...@cs.indiana.edu>.

On Thu, 6 May 2004, Susantha Kumara wrote:

> Hi all,
>
> I would suggest following order and steps to gradually eliminate STL in
> Axis C++ codebase.
>
> std::string
> 1.	Use "char*" instead of "string" wherever possible - need to take
> care of the memory allocation and deallocation
> 2.	Write our own String class to replace the strings left after
> step 1.

I would suggest reversing the priority of 1 and 2.

    1.  Use std::string wherever possible.
    2.  Otherwise, use your own string class.
    3.  Otherwise, use "char *".

The times when you really need number 3 should be very few.

> std::map
> 1.	Review the code base and minimize the use of std::map's
> functions. Replace std::map with arrays or lists where possible
> 2.	Write our own Map class with minimum functionality and use it in
> yet existing places after step 1. Even if we don't use templates to
> write this map class we can make this almost generic if we use a class
> which has
> a.	void* for key
> b.	void* for value
> c.	allocator/deallocator provided externally
> d.	key comparison function provided externally
>
> std::queue
> std::list
> std::stack
> 1.	Probably we can use linked lists to replace these.

I personally believe you will be better off in the long run
if you fix the STL problems by changing the way you use it,
rather than trying to replace it everywhere.

The STL gets a lot of testing.