Solved

Is there a public domain template library that I can incorporate into my code?

Posted on 2000-03-21
3
187 Views
Last Modified: 2013-12-14
Ideally this would be a subset of STL (perhaps with
the names changed systematically to avoid
name conflicts with STL) that I could include in  my
code so that I don't have to rely on STL implementations being consistent.

I am just looking for the basic stuff:  
   Linked lists, vectors, trees
 implemented cleanly and portably.

 Nothing fancy.
0
Comment
Question by:klopter
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 2640781
>> names changed systematically to avoid
>> name conflicts with STL)
You can always use namespaces to prevent these problems.  The STL names are al in the "std" namespace.

>> so that I don't have to rely on STL
>> implementations being consistent.
Why woud this matter?  You should only care about the interface, not the implimentation.  

Sometimes the implimentation MUST be different.  For example streams must eventually contain OS-specific code to read and write from a file.

If you really have to do this, just copy the STL files from your compiler to a new name and modify them to use a different namespace.  Then just use these files.  But I really have to wonder if there is a good reason to do this.
0
 

Author Comment

by:klopter
ID: 2640855
The upshot is that I want to start
using STL, but I just want to start
by dipping my big toe in.  


The code that I am working on does
not use STL.  Maybe that was the
right decision two years, maybe it
isn't now.  

If I start using STL and as a result
we have portability problems, I
will pay the price AND they will
never use STL again.

I am only interested in container
classes at this point.  Nothing
system specific.  

My thought was that if I could snag
a bit of a public domain STL and
use it, I could get that big toe
wet without risking bumping into
portability problems.

Ken
0
 
LVL 22

Expert Comment

by:nietod
ID: 2641251
What compiler/OS are you using and what compiler/OS might you be porting to?  (To get an idea of what sort of problems you might expect).

If you stick to the "core" parts of STL and the less advanced features you are less likley to run into problems and it does sound like you are not goign to be a "power user" and get into the more remote things.  I really don't think you will find problems unless you are forced to use a very old compiler.

>> if I could snag
>> a bit of a public domain STL and
>> use it, I could get that big toe
>> wet without risking bumping into
>> portability problems.
Reasonable, but wrong.  The different versions of STL out there tend to be written to isolate you from differences among compilers.  That is they themselves are non-portable, but they are written so that code that uses them will be portable.  Does that  make sense?  For example, some compilers don't yet support template member functions (template functions that are class members).  The official STL classes use this feature.  So versions of STL that don't support template member functions are "crippled" so that the feature isn't required, plust they may contain additional code so that the missing feature is not usually missed.  Versions of STL that do support template member functions, do have the ful feature.  So the STL code itself will not be portable from a compiler that supports template member functions to a compiler that doesn't suppport them.  However code that uses the STL will be protable, unless it happens to use this feature in a way that the "patched" STL didn't anticipate.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now