To STL or not to STL, that is the question...
I hate the standard template library.
I hate the fact you can't use DEBUG_NEW with it to track down memory leaks.
I hate all the std::blah blah stuff when there's classes in MFC which do virtually the same job but much, much nicer.
I don't even like CArray.
However CPtrArray, CObArray and CStringArray are very, very, very useful.
You can't inherit from any of the STL classes because they don't have virtual destructors so you can't for instance do nice things that you can in MFC like :
Code:
class CServerNames : public CStringArray
{
public:
CServerNames();
virtual ~CServerNames();
} ;
where this class would load in all server names from wherever.
In one line.
Wherever you wanted to put it in the code.
In an MFC environment I don't see any reason to use it. Ever !
I know my comments are very forward, but I'm invoking discussion.
This should be very, very interesting.
Darwen.
Re: To STL or not to STL, that is the question...
[QUOTE]Originally posted by darwen
Quote:
I hate the fact you can't use DEBUG_NEW with it to track down memory leaks.
There's a whole lot of code that is not STL where DEBUG_NEW cannot be used. So that's strike one.
Quote:
I hate all the std::blah blah stuff when there's classes in MFC which do virtually the same job but much, much nicer.
OK. Go sort a CList. Also, std:: is called a namespace. Again, nothing to do with STL, but just basic C++. Strike 2.
Quote:
I don't even like CArray.
Why? It's MFC, isn't it?
Quote:
However CPtrArray, CObArray and CStringArray are very, very, very useful.
If you want all that overhead of CObject added to your classes, go right ahead. Most C++ programmers do not want their classes hamstrung being derived from CObject.
Quote:
You can't inherit from any of the STL classes because they don't have virtual destructors so you can't for instance do nice things that you can in MFC like :
Code:
class CServerNames : public CStringArray
{
public:
CServerNames();
virtual ~CServerNames();
} ;
where this class would load in all server names from wherever.
In one line.
Wherever you wanted to put it in the code.
Let's see the code that loads everything in "one line". Just posting a class without any code is not very convincing.
Code:
class CServerNames
{
public:
CServerNames() { LoadNames(); }
std::vector<std::string> AllMyNames;
void LoadNames()
{
// Code to load server names into AllMyNames
}
};
void foo()
{
CServerNames S; // I've just loaded all the names
}
I guess that's strike 3, but I'll keep going...
Quote:
In an MFC environment I don't see any reason to use it. Ever !
Go sort a CPtrArray, or CStringArray, or CList. You can't unless you write your own code. I can do it in one line of STL code using std::sort. Oh, you must have forgot, STL isn't just about containers, there are a whole lot of algorithm functions (such as std::sort) that work on MFC Array classes. Maybe when you need to sort your CStringArray or call a function that acts on each element of your CPtrArray, you will see for_each() and not know what it does.
Quote:
I know my comments are very forward, but I'm invoking discussion.
Looks like your trolling.
Regards,
Paul McKenzie