Cross platform C++ base library?

Hello, I am looking for a good cross platform C++ 'base class' library for 
things such as strings, containers, and utility functions that are typically 
found in MFC, Qt, etc.  It doesn't need to support GUI.  This is for a C++ 
middleware project.

I realize the default choice is STL, available with standard C++.  But I 
really hate that, as well as the TR9 and upcoming C++0x standards.  I am 
looking for a simpler and more sane alternative similar to the classes found 
in MFC or Qt (but that don't require a licensing or are necessarily part of 
a GUI framework).

Thanks for any suggestions,
David 

0
dc2983 (3206)
12/18/2008 2:57:28 AM
vc.mfc 33608 articles. 0 followers. Follow

29 Replies
978 Views

Similar Articles

[PageSpeed] 38

Well, "simpler" and "more sane" usually says "something that has so many limitations that
it probably isn't usable, takes months to develop, is never quite debugged, and doesn't
solve the real problems"

Use STL.  It's worth the time to learn it.
					joe

On Wed, 17 Dec 2008 18:57:28 -0800, "David Ching" <dc@remove-this.dcsoft.com> wrote:

>Hello, I am looking for a good cross platform C++ 'base class' library for 
>things such as strings, containers, and utility functions that are typically 
>found in MFC, Qt, etc.  It doesn't need to support GUI.  This is for a C++ 
>middleware project.
>
>I realize the default choice is STL, available with standard C++.  But I 
>really hate that, as well as the TR9 and upcoming C++0x standards.  I am 
>looking for a simpler and more sane alternative similar to the classes found 
>in MFC or Qt (but that don't require a licensing or are necessarily part of 
>a GUI framework).
>
>Thanks for any suggestions,
>David 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15978)
12/18/2008 4:33:43 AM
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:8jkjk49hs7l182hjfusdukafukrjjh8725@4ax.com...
> Well, "simpler" and "more sane" usually says "something that has so many 
> limitations that
> it probably isn't usable, takes months to develop, is never quite 
> debugged, and doesn't
> solve the real problems"
>
> Use STL.  It's worth the time to learn it.

Sorry, it's against my religion.  If .NET can produce a great BCL, the C++ 
people should learn from it.

-- David

0
dc2983 (3206)
12/18/2008 5:03:29 AM
"David Ching" <dc@remove-this.dcsoft.com> wrote in message 
news:FA8A0FDA-CC0F-438B-B896-8A696CDBB658@microsoft.com...
> Hello, I am looking for a good cross platform C++ 'base class' library for 
> things such as strings, containers, and utility functions that are 
> typically found in MFC, Qt, etc.  It doesn't need to support GUI.  This is 
> for a C++ middleware project.
>
> I realize the default choice is STL, available with standard C++.  But I 
> really hate that, as well as the TR9 and upcoming C++0x standards.  I am 
> looking for a simpler and more sane alternative similar to the classes 
> found in MFC or Qt (but that don't require a licensing or are necessarily 
> part of a GUI framework).

I don't know if it's stealing, but why not just clip out those things from 
MFC that you like and try to create a scenario such that it compiles and 
runs without all the other junk. Things like CString and CList can be pretty 
much be clipped-out compiled their own; ie. you don't need any of the 
windows wrapper stuff to use the containers (lists, strings, maps) and it's 
all very efficient and well-tested code.

But like I say, not sure if that's allowed. Maybe you have to ask permission 
from Msoft or something? I mean permission to base a library on *just a 
subsection of MFC*. You're allowed to *use* MFC so I don't see why it would 
be illegal "in theory", as long as you're not selling or publishing it.

But ... dunno. I'm not a lawyer.

- Alan Carre


0
alan314 (63)
12/18/2008 11:08:03 AM
David Ching wrote:
> Hello, I am looking for a good cross platform C++ 'base class' library 
> for things such as strings, containers, and utility functions that are 
> typically found in MFC, Qt, etc.  It doesn't need to support GUI.  This 
> is for a C++ middleware project.
> 
> I realize the default choice is STL, available with standard C++.  But I 
> really hate that, as well as the TR9 and upcoming C++0x standards.  I am 
> looking for a simpler and more sane alternative similar to the classes 
> found in MFC or Qt (but that don't require a licensing or are 
> necessarily part of a GUI framework).

Hi David,

as a result of a web search, I found a class similar to CString, but 
whose implementation is done using STL. This way, you should have both 
the cross-platform feature (because the class is built on top of STL), 
and the CString-like public interface:

   CString-like Class Using STL
   http://www.developer.com/net/cplus/article.php/627611

(I seem to recall that in the past I read something similar of that on 
CodeProject, but I'm not sure...)

Unfortunately, I'm not aware of "simplified" versions of std::vector, 
std::map and tr1::shared_ptr.

My first reaction to STL was that of a disagreement (starting from the 
naming convention; in fact, I prefer camelCasing or PascalCasing to 
c_linux_hacker_casing :)

Moreover, I really don't like std::map having 'first' and 'second'; I 
would much more prefer 'Key' and 'Value' (like in C# BCL Dictionary 
container) as naming choice!

However, I learnt the basics of STL containers like vector and map, and 
now I'm glad to use these STL containers (excluding the naming conventions).
For example, I like the non-linear factor (1.5X) policy of vector 
capacity growing (instead I think that MFC's CArray implements the poor 
arithmetic growing factor).

But I'm not an STL guru, e.g. I've not learnt to use STL allocators, yet.

However, I believe that you are a bright programmer and you can master 
STL as well! :)

If you really don't like STL, you could just use STL as the core to 
implement classes with an MFC-like interface (e.g. a David::CArray, 
David::CList, etc. based on std::vector, std::list, etc.). So, you can 
continue using the MFC-like interfaces, and you also have cross-platform 
thanks to STL implementation "under the hood".
(In this case, you just need to program the STL containers only once, 
when you write the *implementation* of your custom classes like 
David::CArray, then you forget about STL, and you use the usual MFC-like 
public interfaces of your custom classes.)

My 2 cents,
Giovanni
0
12/18/2008 12:46:12 PM
Joseph M. Newcomer wrote:

> Use STL.  It's worth the time to learn it.

STL is a very powerful library, no doubt.

It is also designed with extensibility and customizability in mind, I 
mean: the idea of providing custom allocators for STL containers is 
great, as well as the the distinction (decoupling) between the 
containers and the algorithms, and then using the iterators as kind of a 
"wire" to connect between these two elements (containers and algorithms).

However, if one does not need all this power, maybe a library with a 
simpler interface could be used.

I think that this library could be built on top of STL (e.g. using STL 
as a private implementation of this "simple container" library).

However, there are some bad choices in STL, like having 'first' and 
'second' instead of more understandable Key and Value in STL map, IMHO.

Giovanni

0
12/18/2008 12:53:30 PM
David Ching wrote:
> Hello, I am looking for a good cross platform C++ 'base class' library 
> for things such as strings, containers, and utility functions that are 
> typically found in MFC, Qt, etc.  It doesn't need to support GUI.  This 
> is for a C++ middleware project.
> 
> I realize the default choice is STL, available with standard C++.  But I 
> really hate that, as well as the TR9 and upcoming C++0x standards.  I am 
> looking for a simpler and more sane alternative similar to the classes 
> found in MFC or Qt (but that don't require a licensing or are 
> necessarily part of a GUI framework).
> 
> Thanks for any suggestions,
> David

David - Have you looked at boost?  I haven't done anything with it, but 
thought I would mention it as a possibility.

When you do find what you're looking for, please post back and let us 
know what you settled on.

0
nothanks5518 (121)
12/18/2008 1:56:48 PM
"Alan Carre" <alan@twilightgames.com> wrote in message 
news:OJ6ggDQYJHA.1188@TK2MSFTNGP05.phx.gbl...
> I don't know if it's stealing, but why not just clip out those things from 
> MFC that you like and try to create a scenario such that it compiles and 
> runs without all the other junk. Things like CString and CList can be 
> pretty much be clipped-out compiled their own; ie. you don't need any of 
> the windows wrapper stuff to use the containers (lists, strings, maps) and 
> it's all very efficient and well-tested code.
>

This used to be easy (you could even just take cstring.h and cstring.cpp and 
compile them directly into a non-MFC project), but then MS refactored these 
things into ATL, and then it became very hard.


> But like I say, not sure if that's allowed. Maybe you have to ask 
> permission from Msoft or something? I mean permission to base a library on 
> *just a subsection of MFC*. You're allowed to *use* MFC so I don't see why 
> it would be illegal "in theory", as long as you're not selling or 
> publishing it.
>
> But ... dunno. I'm not a lawyer.
>

Thanks Alan.  At this point I"m looking for a ready-to use library and not 
have to fight to get MS stuff to build with GNU, etc., and you're right, the 
licensing may be an issue.  I don't think using MFC source code in a cross 
platform manner is going to work.

I see wxWidgets has a wxBase library which looks promising.

Thanks,
David


0
dc2983 (3206)
12/18/2008 2:04:24 PM
Thanks G.  At this point I think just using the base classes from a cross 
platform framework like Qt (QtCore) or wxWidgets (wxBase) is my best bet.

Cheers,
David


"Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in message 
news:u4N3j6QYJHA.4272@TK2MSFTNGP03.phx.gbl...
> Hi David,
>
> as a result of a web search, I found a class similar to CString, but whose 
> implementation is done using STL. This way, you should have both the 
> cross-platform feature (because the class is built on top of STL), and the 
> CString-like public interface:
>
>   CString-like Class Using STL
>   http://www.developer.com/net/cplus/article.php/627611
>
> (I seem to recall that in the past I read something similar of that on 
> CodeProject, but I'm not sure...)
>
> Unfortunately, I'm not aware of "simplified" versions of std::vector, 
> std::map and tr1::shared_ptr.
>
> My first reaction to STL was that of a disagreement (starting from the 
> naming convention; in fact, I prefer camelCasing or PascalCasing to 
> c_linux_hacker_casing :)
>
> Moreover, I really don't like std::map having 'first' and 'second'; I 
> would much more prefer 'Key' and 'Value' (like in C# BCL Dictionary 
> container) as naming choice!
>
> However, I learnt the basics of STL containers like vector and map, and 
> now I'm glad to use these STL containers (excluding the naming 
> conventions).
> For example, I like the non-linear factor (1.5X) policy of vector capacity 
> growing (instead I think that MFC's CArray implements the poor arithmetic 
> growing factor).
>
> But I'm not an STL guru, e.g. I've not learnt to use STL allocators, yet.
>
> However, I believe that you are a bright programmer and you can master STL 
> as well! :)
>
> If you really don't like STL, you could just use STL as the core to 
> implement classes with an MFC-like interface (e.g. a David::CArray, 
> David::CList, etc. based on std::vector, std::list, etc.). So, you can 
> continue using the MFC-like interfaces, and you also have cross-platform 
> thanks to STL implementation "under the hood".
> (In this case, you just need to program the STL containers only once, when 
> you write the *implementation* of your custom classes like David::CArray, 
> then you forget about STL, and you use the usual MFC-like public 
> interfaces of your custom classes.)
>
> My 2 cents,
> Giovanni 

0
dc2983 (3206)
12/18/2008 2:06:30 PM
BobF wrote:

> David - Have you looked at boost?  I haven't done anything with it, but 
> thought I would mention it as a possibility.

Hi Bob,

I think that David's spirit is against the complexity of boost...

Giovanni

0
12/18/2008 2:18:10 PM
David Ching wrote:

> At this point I think just using the base classes from a 
> cross platform framework like Qt (QtCore) or wxWidgets (wxBase) is my 
> best bet.

Thanks David.

You're right: e.g. I'm reading that wxBase offers a wxString class, 
which has a Trim() method.
Instead, with STL std::string you need to implement it yourself with 
something like this:

<code>

string::iterator i;

for (i = str.begin(); i != str.end(); ++i)
{
     if (!isspace(*i))
         break;
}

if (i == str.end())
     str.clear();
else
     str.erase(str.begin(), i);

</code>

wxString has also StartsWith() method ready "off-the-shelf", instead the 
corresponding STL std::string would be something like:

<code>

if ( str.find( substring ) == 0 )
   return true;
else
   return false;

</code>

....and more.

G
0
12/18/2008 2:33:37 PM
I have to say STL.  I know its hard to use (after 18 years of C++, I still 
don't know half of what it can do), but it gets the job done, and it gets it 
done well.

AliR.

"David Ching" <dc@remove-this.dcsoft.com> wrote in message 
news:FA8A0FDA-CC0F-438B-B896-8A696CDBB658@microsoft.com...
> Hello, I am looking for a good cross platform C++ 'base class' library for 
> things such as strings, containers, and utility functions that are 
> typically found in MFC, Qt, etc.  It doesn't need to support GUI.  This is 
> for a C++ middleware project.
>
> I realize the default choice is STL, available with standard C++.  But I 
> really hate that, as well as the TR9 and upcoming C++0x standards.  I am 
> looking for a simpler and more sane alternative similar to the classes 
> found in MFC or Qt (but that don't require a licensing or are necessarily 
> part of a GUI framework).
>
> Thanks for any suggestions,
> David 


0
AliR3470 (3234)
12/18/2008 4:29:48 PM
"David Ching" <dc@remove-this.dcsoft.com> wrote in message 
news:1F91C76D-2A6A-4B92-B330-DA340AC2D6F5@microsoft.com...
>> MFC that you like and try to create a scenario such that it compiles and 
>> runs without all the other junk. Things like CString and CList can be 
>> pretty much be clipped-out compiled their own; ie. you don't need any of
>
> This used to be easy (you could even just take cstring.h and cstring.cpp 
> and compile them directly into a non-MFC project), but then MS refactored 
> these things into ATL, and then it became very hard.

Oh no! OF COURSE not that code! I was referring to MFC, not this "active MFC 
god-knows-what-the-hell-hit-it" VC8 llBu hSit. I know what you're looking 
for. I have the sources for VC6 on hand and I could probably find 4.2 
somewhere.

> Thanks Alan.  At this point I"m looking for a ready-to use library and not 
> have to fight to get MS stuff to build with GNU, etc., and you're right, 
> the licensing may be an issue.  I don't think using MFC source code in a 
> cross platform manner is going to work.

Well there's nothing really platform specific that I can think of with the 
old stuff. Except maybe that TCHAR business... but that's all #defines so 
you can just add in the bits you need.

But anyway, ya. potential licensing is a problems... That I cannot answer. 
It may be fine if you've purchased VC6 in the past to use that source code 
in your projects. I mean if you don't alter it what's the difference? Is 
taking away features considered "building on someone else's intellectual 
property"?

Actually... in this case I think taking away features *does* amount to added 
value, so I take it back ;)

- Alan Carre


0
alan314 (63)
12/18/2008 6:02:43 PM
I was ready to suggest wxBase, but it looks like you have
discovered it already.
I have very good experience with the complete wxWidgets library.


But I would really recommend learning STL in the long run.
It is really powerfull, and I find the design quite elegant
(ok, I cannot say the same about the implementation, but
you don't have to read the sources :-)

To address Giovanni's complaint about 'first' and 'second':
it is because they reuse std::pair, which is not always used
in std::map context.
Not sure if creating an identical class with different
member names just for the map would have been a good idea...


-- 
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
12/19/2008 5:00:01 AM
Hi Mihai,

Mihai N. wrote:

> But I would really recommend learning STL in the long run.
> It is really powerfull, 

100% agree on the power of STL. I think that it is one the most 
important features of this library.

> and I find the design quite elegant
> (ok, I cannot say the same about the implementation, but
> you don't have to read the sources :-)

I find kind of hard to follow the STL implementation code, too :) (at 
least the version provided with Visual C++). I think that advanced 
template programming techniques are required for this kind of job... 
(probably Alexandrescu's book "Modern C++ Design" would be a required 
reading :)


> To address Giovanni's complaint about 'first' and 'second':
> it is because they reuse std::pair, which is not always used
> in std::map context.
> Not sure if creating an identical class with different
> member names just for the map would have been a good idea...

I don't know... but frankly speaking the public interfaces of some STL 
classes are not good, IMHO.
For example, I discussed STL std::string lacking explicit 
ready-off-the-shelf trim, left, right, startsWith, endsWith, etc. public 
methods.

Moreover, if you consider std::map, I think that there is no method like 
contains() that returns a bool, to check if the an item with a given key 
is stored in the map.
Instead, I think that this kind of code should be used (using find() 
method and compare the resulting iterator with .end() :(

   // Check if 'theKey' is a key stored in the map 'myMap'
   map<...>::const_iterator it;
   it = myMap.find( theKey );
   if ( it == myMap.end() )
      ... theKey is not in the map

I would appreciate a method like map::contains(), to just work like this:

   if ( myMap.contains( theKey ) )
      ....

Moreover, it seems to me that there is no method to get a list of all 
the keys stored in the map.
Instead, I think that you should iterate on the map content (e.g. using 
begin() to start), and build a collection by yourself, adding 
iterator->first (i.e. the key) values to an instance of some collection 
class.
Instead, .NET BCL Dictionary container has Keys and Values collections 
ready out-of-the-box :)

So, to summarize, STL is very powerful and the design using the synergy 
of containers+iterators+algorithms is very elegant, no doubt. But the 
interfaces of some of its classes could be much better, IMHO.

I sometimes think of deriving some class from std::string or std::map, 
and write some useful methods to make the interface of these classes 
more rich and useful.

Giovanni



0
12/19/2008 11:14:26 AM
"Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in message 
news:OiLBRscYJHA.2124@TK2MSFTNGP04.phx.gbl...
> So, to summarize, STL is very powerful and the design using the synergy of 
> containers+iterators+algorithms is very elegant, no doubt. But the 
> interfaces of some of its classes could be much better, IMHO.
>
> I sometimes think of deriving some class from std::string or std::map, and 
> write some useful methods to make the interface of these classes more rich 
> and useful.
>

Thanks G.  You have a way of saying what I mean better than I do!  :-)

I don't see the point of an elegant design that is not elegant to use.  That 
may work for museum showpieces, but not for software libraries.  ;)

-- David 

0
dc2983 (3206)
12/19/2008 7:32:30 PM
Giovanni Dicanio <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in 
news:OiLBRscYJHA.2124@TK2MSFTNGP04.phx.gbl:
> Moreover, if you consider std::map, I think that there is no method 
like 
> contains() that returns a bool, to check if the an item with a given 
key 
> is stored in the map.
> Instead, I think that this kind of code should be used (using find() 
> method and compare the resulting iterator with .end() :(
> 
>    // Check if 'theKey' is a key stored in the map 'myMap'
>    map<...>::const_iterator it;
>    it = myMap.find( theKey );
>    if ( it == myMap.end() )
>       ... theKey is not in the map
> 
> I would appreciate a method like map::contains(), to just work like 
this:
> 
>    if ( myMap.contains( theKey ) )
>       ....

You could always do:
bool contains(map<...> const& myMap, type theKey)
{
    	return myMap.end() != myMap.find(theKey);
}

or
template bool <typename K, typename V>
contains(map<T, V> const& myMap, V const& theKey)
{
    	return myMap.end() != myMap.find(theKey);
}
(my syntax might be off, I don't write templates too often)


That's actually one thing I like about STL - they didn't try to write 
every function that anyone could possibly want. Sure, 'contains' would be 
convenient. But 'find' can be used to do exactly the same thing, and it 
provides more functionality.

Dave Connet
0
stuff7507 (45)
12/19/2008 8:52:13 PM
David Ching wrote:

> Thanks G.  You have a way of saying what I mean better than I do!  :-)

Thanks David :)

....but I really have to improve my "Italglish" ;)

G

0
12/19/2008 9:25:48 PM
See below...
On Thu, 18 Dec 2008 13:53:30 +0100, Giovanni Dicanio
<giovanniDOTdicanio@REMOVEMEgmail.com> wrote:

>Joseph M. Newcomer wrote:
>
>> Use STL.  It's worth the time to learn it.
>
>STL is a very powerful library, no doubt.
>
>It is also designed with extensibility and customizability in mind, I 
>mean: the idea of providing custom allocators for STL containers is 
>great, as well as the the distinction (decoupling) between the 
>containers and the algorithms, and then using the iterators as kind of a 
>"wire" to connect between these two elements (containers and algorithms).
****
The extensibility is vaguely interesting, but the flexibility of vector and map are
definitely worth the effort to learn them.  Custom allocators are essential (one of the
problems of MFC for years was that you could not provide custom allocators)
****
>
>However, if one does not need all this power, maybe a library with a 
>simpler interface could be used.
****
I have a few patterns I use.  I don't try to reinvent them each time from basic
principles, I just copy-and-paste them now that they work.  No allocators, for example.
****
>
>I think that this library could be built on top of STL (e.g. using STL 
>as a private implementation of this "simple container" library).
****
I'm less tempted by this idea.  Once you learn a few STL patterns, it is easy to use
because you don't need to do anything ever again to reinvent that pattern.  So I struggled
for a day or so to get map in my head, got it working, and would now need to redo all that
effort, even though I've used it in many apps since.
****
****
>
>However, there are some bad choices in STL, like having 'first' and 
>'second' instead of more understandable Key and Value in STL map, IMHO.
****
I never understood the poor choice of 'first' and 'second' either.
****
>
>Giovanni
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15978)
12/19/2008 9:33:26 PM
But C# is not C++; CLR gives a lot more power and flexibility for a number of features
that make it easier to use C#.  I like the language.  But since I have no paying customers
who care about it, I find little cause to use it.  So what else is there to use other than
STL?  Boost has acceptance problems, for example ("We don't use open-source code in our
products"--never mind that the GPL and the Boost license are completely different!)
					joe

On Wed, 17 Dec 2008 21:03:29 -0800, "David Ching" <dc@remove-this.dcsoft.com> wrote:

>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:8jkjk49hs7l182hjfusdukafukrjjh8725@4ax.com...
>> Well, "simpler" and "more sane" usually says "something that has so many 
>> limitations that
>> it probably isn't usable, takes months to develop, is never quite 
>> debugged, and doesn't
>> solve the real problems"
>>
>> Use STL.  It's worth the time to learn it.
>
>Sorry, it's against my religion.  If .NET can produce a great BCL, the C++ 
>people should learn from it.
>
>-- David
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15978)
12/19/2008 9:35:51 PM
Did you look at www.mainsoft.com ?
				joe

On Thu, 18 Dec 2008 06:04:24 -0800, "David Ching" <dc@remove-this.dcsoft.com> wrote:

>"Alan Carre" <alan@twilightgames.com> wrote in message 
>news:OJ6ggDQYJHA.1188@TK2MSFTNGP05.phx.gbl...
>> I don't know if it's stealing, but why not just clip out those things from 
>> MFC that you like and try to create a scenario such that it compiles and 
>> runs without all the other junk. Things like CString and CList can be 
>> pretty much be clipped-out compiled their own; ie. you don't need any of 
>> the windows wrapper stuff to use the containers (lists, strings, maps) and 
>> it's all very efficient and well-tested code.
>>
>
>This used to be easy (you could even just take cstring.h and cstring.cpp and 
>compile them directly into a non-MFC project), but then MS refactored these 
>things into ATL, and then it became very hard.
>
>
>> But like I say, not sure if that's allowed. Maybe you have to ask 
>> permission from Msoft or something? I mean permission to base a library on 
>> *just a subsection of MFC*. You're allowed to *use* MFC so I don't see why 
>> it would be illegal "in theory", as long as you're not selling or 
>> publishing it.
>>
>> But ... dunno. I'm not a lawyer.
>>
>
>Thanks Alan.  At this point I"m looking for a ready-to use library and not 
>have to fight to get MS stuff to build with GNU, etc., and you're right, the 
>licensing may be an issue.  I don't think using MFC source code in a cross 
>platform manner is going to work.
>
>I see wxWidgets has a wxBase library which looks promising.
>
>Thanks,
>David
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15978)
12/19/2008 9:38:08 PM
The biggest problem with the templates is that if you make an error, you get to deal with
the problem in terms of some really bizarre and incomprehensible syntax error messages. It
works extremely well when everything goes right, but is a bit of a pain to figure out
which mistake you made when something goes wrong.

I've been trying for some years now, but I really find the convoluted templates of STL to
be incomprehensible.  But, as observed, I really don't have to read them.  Much.
				joe

On Fri, 19 Dec 2008 12:14:26 +0100, Giovanni Dicanio
<giovanniDOTdicanio@REMOVEMEgmail.com> wrote:

>Hi Mihai,
>
>Mihai N. wrote:
>
>> But I would really recommend learning STL in the long run.
>> It is really powerfull, 
>
>100% agree on the power of STL. I think that it is one the most 
>important features of this library.
>
>> and I find the design quite elegant
>> (ok, I cannot say the same about the implementation, but
>> you don't have to read the sources :-)
>
>I find kind of hard to follow the STL implementation code, too :) (at 
>least the version provided with Visual C++). I think that advanced 
>template programming techniques are required for this kind of job... 
>(probably Alexandrescu's book "Modern C++ Design" would be a required 
>reading :)
>
>
>> To address Giovanni's complaint about 'first' and 'second':
>> it is because they reuse std::pair, which is not always used
>> in std::map context.
>> Not sure if creating an identical class with different
>> member names just for the map would have been a good idea...
>
>I don't know... but frankly speaking the public interfaces of some STL 
>classes are not good, IMHO.
>For example, I discussed STL std::string lacking explicit 
>ready-off-the-shelf trim, left, right, startsWith, endsWith, etc. public 
>methods.
>
>Moreover, if you consider std::map, I think that there is no method like 
>contains() that returns a bool, to check if the an item with a given key 
>is stored in the map.
>Instead, I think that this kind of code should be used (using find() 
>method and compare the resulting iterator with .end() :(
>
>   // Check if 'theKey' is a key stored in the map 'myMap'
>   map<...>::const_iterator it;
>   it = myMap.find( theKey );
>   if ( it == myMap.end() )
>      ... theKey is not in the map
>
>I would appreciate a method like map::contains(), to just work like this:
>
>   if ( myMap.contains( theKey ) )
>      ....
>
>Moreover, it seems to me that there is no method to get a list of all 
>the keys stored in the map.
>Instead, I think that you should iterate on the map content (e.g. using 
>begin() to start), and build a collection by yourself, adding 
>iterator->first (i.e. the key) values to an instance of some collection 
>class.
>Instead, .NET BCL Dictionary container has Keys and Values collections 
>ready out-of-the-box :)
>
>So, to summarize, STL is very powerful and the design using the synergy 
>of containers+iterators+algorithms is very elegant, no doubt. But the 
>interfaces of some of its classes could be much better, IMHO.
>
>I sometimes think of deriving some class from std::string or std::map, 
>and write some useful methods to make the interface of these classes 
>more rich and useful.
>
>Giovanni
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15978)
12/19/2008 9:40:39 PM
> I find kind of hard to follow the STL implementation code, too :) (at 
> least the version provided with Visual C++). I think that advanced 
> template programming techniques are required for this kind of job... 
> (probably Alexandrescu's book "Modern C++ Design" would be a required 
> reading :)

Few years I have browsed "Modern C++ Design" in a Borders store.
And I was ashamed to discover that my rusty-old-style C++ is not good
enough, and I did not understand a thing.
So I have set as my goal to get better.
For the next year I did a lot of reading, experimenting, writing
stuff, as much as possible by the new standard.
And at the end of the year I have bought the book, read it all,
and understood it all.
Now I can understand what is going on, and I can even write some useful
stuff using templates. Far from mastery, but comes in handy once in a while.



> For example, I discussed STL std::string lacking explicit 
> ready-off-the-shelf trim, left, right, startsWith, endsWith, etc. public 
> methods.

Here are also some problems with C/C++ itself, not with STL.
There is no info, for instance, on what is the code page of the strings.
Even wchar_t can be 16 or 32 bits (and if you read the standard, pretty much
anything) and also it does not mean Unicode.

In order to implement a proper "left" you have to know a lot about the
characters in the string. You cannot remove a base character and leave
the following combining characters "hanging"

The current string classes are just a slightly smarter container.


> Moreover, it seems to me that there is no method to get a list of all 
> the keys stored in the map.

A map is a containter.
You want all the keys, the result should be some other kind of container.
If they put it in a list, you would want it in a vector.
I think what STL did was just fine: a powerfull set of APIs, which
makes it very easy to write everything you want in 2-3 lines of code.
You get to appreciate some of it's power when need to change the type
of a container and discover that all you need to do is change the
declaration, and all processing you do on it remains (almost) the same.

Anyway, it is a tool.
Good for some things, not soo good for others.
Knowing how to use all the tools out there allows you to choose the best
one for the job and that makes you a better craftman,


-- 
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
12/20/2008 1:10:26 AM
> ****
> I never understood the poor choice of 'first' and 'second' either.
> ****

"it is because they reuse std::pair, which is not always used
in std::map context."


-- 
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
0
12/20/2008 1:12:18 AM
Joseph M. Newcomer wrote:
> But C# is not C++; CLR gives a lot more power and flexibility for a
> number of features that make it easier to use C#.  I like the
> language.  But since I have no paying customers who care about it, I
> find little cause to use it.  So what else is there to use other than
> STL?

> Boost has acceptance problems, for example ("We don't use
> open-source code in our products"--never mind that the GPL and the
> Boost license are completely different!)

Well, this is a point of view. In my company we use boost everywhere. The policy
is in the other side ( "we don't use propietary libraries" -with a very few
exceptions). To add more information: We develop cross plattform telecom
applications (windows, linux, solaris). Boost has a huge value for us.

Regards


--
Cholo Lennon
Bs.As.
ARG



0
12/22/2008 7:36:01 PM
>In my company we use boost everywhere. The policy
>is in the other side ( "we don't use propietary libraries" -with a very few
>exceptions). To add more information: We develop cross plattform telecom
>applications (windows, linux, solaris). Boost has a huge value for us.

Out of interest, what do you use to develop/debug with on
Linux/Solaris? I've been watching a colleague use Eclipse/CDT and from
what I can see it's nowhere near as nice to debug with as VS when
using STL since there's no visualizers for STL collections like there
are in newer version of VS.

Dave
0
davidl7375 (2061)
12/22/2008 9:39:51 PM
See below...
On Mon, 22 Dec 2008 17:36:01 -0200, "Cholo Lennon" <chololennon@hotmail.com> wrote:

>Joseph M. Newcomer wrote:
>> But C# is not C++; CLR gives a lot more power and flexibility for a
>> number of features that make it easier to use C#.  I like the
>> language.  But since I have no paying customers who care about it, I
>> find little cause to use it.  So what else is there to use other than
>> STL?
>
>> Boost has acceptance problems, for example ("We don't use
>> open-source code in our products"--never mind that the GPL and the
>> Boost license are completely different!)
>
>Well, this is a point of view. In my company we use boost everywhere. The policy
>is in the other side ( "we don't use propietary libraries" -with a very few
>exceptions). To add more information: We develop cross plattform telecom
>applications (windows, linux, solaris). Boost has a huge value for us.
****
I didn't say their attitude made sense.  I have suggested boost to several clients with
the same reaction, and it turns out their legal people say "no open source" as a policy.
They can't tell the difference between a FreeBSD license, a Boost license, a GPL, or a
Creative Commons (to name the ones most often important).  The technologists find this
laughable, but they can't use sensible technologies as a result.
				joe
****
>
>Regards
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15978)
12/23/2008 2:48:39 AM
David Lowndes wrote:
>> In my company we use boost everywhere. The policy
>> is in the other side ( "we don't use propietary libraries" -with a
>> very few exceptions). To add more information: We develop cross
>> plattform telecom applications (windows, linux, solaris). Boost has
>> a huge value for us.
>
> Out of interest, what do you use to develop/debug with on
> Linux/Solaris?

Eclipse CDT

> I've been watching a colleague use Eclipse/CDT and from
> what I can see it's nowhere near as nice to debug with as VS when
> using STL since there's no visualizers for STL collections like there
> are in newer version of VS.

Yes, you're right, it's difficult to debug STL code but you can live with that.
Nothing to say...VS has one of the best debuggers. In the other side I have to
say that Eclipse CDT is a very good IDE with some nice points like the
intellisense, it's works very well most of the time! :-)

>
> Dave

Regards

--
Cholo Lennon
Bs.As.
ARG



0
12/23/2008 9:54:19 PM
Joseph M. Newcomer wrote:
> See below...
> On Mon, 22 Dec 2008 17:36:01 -0200, "Cholo Lennon"
> <chololennon@hotmail.com> wrote:
>
>> Joseph M. Newcomer wrote:
>>> But C# is not C++; CLR gives a lot more power and flexibility for a
>>> number of features that make it easier to use C#.  I like the
>>> language.  But since I have no paying customers who care about it, I
>>> find little cause to use it.  So what else is there to use other
>>> than STL?
>>
>>> Boost has acceptance problems, for example ("We don't use
>>> open-source code in our products"--never mind that the GPL and the
>>> Boost license are completely different!)
>>
>> Well, this is a point of view. In my company we use boost
>> everywhere. The policy is in the other side ( "we don't use
>> propietary libraries" -with a very few exceptions). To add more
>> information: We develop cross plattform telecom applications
>> (windows, linux, solaris). Boost has a huge value for us.
> ****
> I didn't say their attitude made sense.

Ok, I understood you very well. I just wanted to show another point where boost
has not acceptance problems :-)

> I have suggested boost to
> several clients with the same reaction, and it turns out their legal
> people say "no open source" as a policy. They can't tell the
> difference between a FreeBSD license, a Boost license, a GPL, or a
> Creative Commons (to name the ones most often important).  The
> technologists find this laughable, but they can't use sensible
> technologies as a result.
> joe
> ****


--
Cholo Lennon
Bs.As.
ARG



0
12/23/2008 10:00:01 PM
>> Out of interest, what do you use to develop/debug with on
>> Linux/Solaris?
>
>Eclipse CDT
>
>> I've been watching a colleague use Eclipse/CDT and from
>> what I can see it's nowhere near as nice to debug with as VS when
>> using STL since there's no visualizers for STL collections like there
>> are in newer version of VS.
>
>Yes, you're right, it's difficult to debug STL code but you can live with that.
>Nothing to say...VS has one of the best debuggers. In the other side I have to
>say that Eclipse CDT is a very good IDE with some nice points like the
>intellisense, it's works very well most of the time! :-)

Cheers for that - I just wanted to be sure we weren't missing
something since this is our first use of such tools and developing on
Unix platforms.

Merry Christmas
Dave
0
davidl7375 (2061)
12/24/2008 12:26:49 AM
Reply:

Similar Artilces:

Microsoft Visual C++ Runtime Library Error Message #2
Hi all, Does anyone know how to solve this? When i clicked on any mails in my Outlook 2000, it prompts out this error message (dialog box) saying "Microsoft Visual C++ Runtime Library - Program: C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE. - abnormal program termination." Once I clicked on the OK button, the whole Outlook 2000 just shuts down and I am unable to view any mails at all. Please help!! :( ...

C-RunTime or Win32
This is a big question I always get in my mind, that Should I use C-Run Time Library functions or Win32 Functions? e.g. A simple task, open a file, if exist, open for read or open as append for write, what is its path, directory, extension, file attributes, etc. Now, all these taks, we need in our every projects, and hence I hace this question, that CRTL or Win32. Thanks for your vital views. Tom Alter wrote: > This is a big question I always get in my mind, that Should I use C-Run Time Library > functions or Win32 Functions? > e.g. A simple task, open a file, if exist, open for r...

visual studio c++ .net 2005 and mfc?
I've been using VC++ 6.0 and MFC for a few years now and I'm planning to get VC++ .NET 2005 when it comes out. I've heard MFC will be included in VC++ 2005, but I haven't been able to find anything about it on Microsoft's site. Which versions will it be included in? I know it's not in the Express version. If MFC will be included, where can I find what changes there will be? Will MFC continue to be supported in the future? If anyone's got a direct link to any MFC and VC++ .NET 2005 information please post it. And I'm so confused to which product line has ...

is there anyway to access funcion written in c by vc++
hi Is this is possible to access ,a function written in C by VC++. Arbind >Is this is possible to access ,a function written in C by VC++. Yes. I suspect you need to know about using extern "C" to tell the compiler that your function is 'C' rather than C++. For example: extern "C" int MyFn( int p1 ); You often use it like this: extern "C" { #include "Your_C_Header.g" } Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq >#include "Your_C_Header.g" or even #include "Your_C_Header.h" who put that g key in the wa...

data base query
I have a workbook with 2 work sheets. Eacch contains data from a database query( 2 different databases) Is it possible to create a pivot table from the 2 sheets ? ...

Creating Cross-Project Links
Hi 1). What is the usage of Creating Cross-Project Links ? As I understand, "Cross-project links are useful when two or more projects have only a few tasks that affect one another. For example, a milestone within a development project might trigger a task in an advertising campaign project." 2). How it is implemented in Project 2007 ? When I copied the task from the source project into my project ( target project ) using "Paste Special", the new task I created become another task in my target project. My observation is both task ( ie. task in the source...

Customer Cross Reference
2nd Request - Posted a few Months Ago, No Reply --------------------------------------------------------------------------- Has anyone out there used the Customer Part Number Cross Ref v8.0? I loaded a customer list the other day. When I entered the Customer Number on the Sales Order, it was instantly converted over to our number. Worked Great... I'm wondering if there is a way to automatically reference the original Customer Number on the Packing List and/Or Invoice or is that something that needs to be manually typed in. I tried adding notes, but I don't know if they carry down...

e2k3 users cannot see e5.5 org form library
Hello guys, I have all e2k3 users who cannot see the org form library homed on e5.5 servers. all e5.5 users can view the org form library. Here is the setup: mixed-mode exchange 5.5 org, with 1 site on e5.5 and 1 mixed-mode site with 1 e2k3 server and 1 e5.5 server. e5.5 users in site 1 can use the org form library, no problem. e5.5 users in site2 can use the org form library, no problem. e2k3 users in site2 can NOT see the org form library. The org form library folder homed in site1 is replicated to site2 on both the e5.5 and e2k3 servers. Access to all other public folders are worki...

No "Move Mailbox" cross site migration
Hi everybody: We have a forest with subdomains, the main domain is AD 2000 and has 1 Cluster Exchange 2003 SP1, 1 Server Exchange 2003 SP1 with ADC SP1 and SRS, and 3 Exchange 5.5 in the same Exchange 5.5 site. We have 8 subdomains in AD2000 with Exchange 5.5 SP4 server with hotfix applied for cross-site in each subdomain, and they had an own site in Exchange 5.5. We are trying to consolidate and move all mailbox and public folders to the Exchange 2003 cluster, we did the domainprep in each subdomain and create a RUS in the Exchange 2003 cluster to each subdomain. When we tried to move cros...

change font color based on value?
Is there a simple way to test a column's content for its value (date) and assign a color to the displayed date based upon a date range? Yeah, I'm new to Excel; normally a database kind of guy (or would use Crystal Reports and create formula fields that would display the date only if it was within a certain range and assign a font & color to it). Thanks- --Mike-- Chain Reaction Bicycles http://www.ChainReactionBicycles.com > Is there a simple way to test a column's content for its value (date) and > assign a color to the displayed date based upon a date range? ...

Filtering data based on historical values
Hello everyone, I am trying to sort a list of temperatures to analyze a chillers operation. The chiller turns on when the outside air temperature is 80, and turns off when the outside air temperature is 70. I am trying to find the time when the chiller is on (temperature was above 80 and didn't drop below 70) and the temperature is between 70 and 75. All I need is excel to display a 1 if it is on (and between 70-75) or 0 if off, because every 1 is a unit of time. All the sorts I have tried are unable to look back and see if it was turned on, because it may have been above 80 t...

Cross table
Hi everybody !! i come again here with a problem i can seem to solve :s i hope someone will be able to give me a hand on this... here it is : i have a sheet with 2 rows: location and activity. several activities can be found in one location, even several of the same activities. schematic exemple location activity 1 A 1 B 2 A 3 A 3 B 3 C 4 B 4 C I would like to create something that give me as a result a sheet where we can see the spatial relations between the activities. so i would have all...

How can get Microsoft Excel on to my p.c
Could someone help me as i do not have a clue as what i need to do all i have been told is that i need Excel to beable to do my spreadsheets. HELP!!! Buy it. -- Regards; Rob ------------------------------------------------------------------------ "Rebecca" <Rebecca@discussions.microsoft.com> wrote in message news:63F86D33-FCCE-4BB3-A84C-E259DA855EA6@microsoft.com... > Could someone help me as i do not have a clue as what i need to do all i have > been told is that i need Excel to beable to do my spreadsheets. > HELP!!! Trial versions of Excel are available: ...

cross-reference
I created a cross reference in word to a section of my document that has a heading of 'Heading 3' I used Heading for the reference type and for Insert reference to I used Heading Number (Full context). I was expecting to get something like this 4.8.2 but instead I just got 0. is there some setting somewhere that needs to be tweaked? Make sure that numbering is correctly applied to your headings. If you are using Word 2007, you can choose the "1 Heading 1 1.1 Heading 2 1.1.1 Heading 3" format at Home tab | Multilevel List. If you are using Word 2003, see http://www...

cross reference
Greeting all, Hope you experts can help me with following issue. I have 2 order information spreadsheets, the first one has a column which is our product codes, the second one is a reference which has 2 columns map our product codes to customers product codes. Is there any easy way in Excel which can replace our product codes in first excel file with our customer product codes in second excel file? I know I can use Access to do that, just want find out a simple way in Excel. Do I need to write any VB ? Thank you very much in advance!! ------------------------------------------------ ~~...

Calling mangled c++ function from non-mangled C++ function
Hi, I am writing a dll for C# application. My dll functions calls third party dll in which some functions are mangled and some non-mangled fucntions. But when I crate my dll with namespace mangling disable I got the linked error' Unresolved external symbols' for the functions which are mangled in thrid party dll. I know what's the issue. But If I eable the namespace mangling, it works fine. All these i know very well. So my question Is it possible to call a namespace mangled function from a dll in which namespace mangling is disabled? Any comment wuld be appreciated.... ...

Type checking from VBA to C++?
I'm new to VB/VBA and calling functions in external DLLs from VB/VBA. If I declare a variable in VBA, assign a value and then call a C++ function in a DLL, is any type checking down between VBA and the C++ function? So if I declare a Long identifier in VBA and then call a function that expects an enum type in C++, will the call be flagged for type mismatch? Thanks. Les No, there is no type checking, not even ByRef/ByVal checking. If you pass a value to a C parameter that requires an address, you'll blow up. In your specific example of a VBA Long passed to a C++ enum...

File Cross Checking
All: I need your help in this issue: I have a folder with 100 of PDF files and i have an excel spread sheet sheet of a list of files I need to check against the folder if my excel list have those files. How do I do it in a faster way? Thanks in advance. Alish. ...

C function prototype
Is that for Class/Object function prototype, I must define the function in header file or .cpp file. MyClass::functionA(); MyClass::functionB(); but for C function prototype, I don't have to define if it's put before the main() function the following is not needed - void stradd (char *s1, char *s2); void stradd (char *s1, int i); ========= #include <iostream> // cannot be iostream.h?? #include <stdio.h> #include <string.h> #include <comdef.h> #include <conio.h> #include <windows.h> // must need for SYSTEMTIME //must need C/C++ > General...

Determine a result of one column based on conditions in two column
Example Col A Col B Count the number of a's in Col B only when an x is in Col A x a x a Result should be 2 y a z p I can't figure it out x t x m Thanks try this =SUMPRODUCT(--(A2:A7="x"),--(B2:B7="a")) -- Hope this help Please click the Yes button below if this post have helped answer your needs Thank You cheers, francis "tel703" wrote: > Example > Col A Col B Count the number of a...

How do I cross out a word in Publisher?
I have copied a Word document into a Publisher document. In the Word document there are some words that are crossed out. I want them to show as crossed out in my Publisher document...but they aren't. How do I cross out words in Publisher? You will need to draw a line and place it over the word. Grouping it with the textbox will keep it in place (as long as you don't change the size of the box). -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "NATCH-9" <NATCH-9@discussions.microsoft.com> wrote in me...

Copying Data Down the Column But Only Based on What's in Column A
Hello: I have four columns in an Excel spreadsheet. Column A ("Item Number") is a list of inventory items. Column B ("Location Code") is to contain the phrase "CH" in each cell of column B. Column C ("Order Point Qty") contains quantities in each cell of column C. Column D ("Number of Days") contains the number "10" in each cell of column D. At the end of this posting is VBA code for a macro in Excel's Visual Basic Editor that I am using to essentially create this spreadsheet. I am having trouble with the fo...

Re: data return based on two criteria #2
Hello, Can I use the same formula for the below requirement? Sheet1 Column A - Assembly numbers (numbers repeats) Column B - prepart (numbers repeats) Column C - prepart description (description repeats) Sheet 2 Column A - assembly partnumber Column b1 : Z1 - prepart description I would like to return corresponding prepart number Eg. Data base A B C X 123 aaaaaa Z 123 aaaaaa A1 F002 aaaaaa Z2 F002 aaaaaa C3 456 bbbbbb D2 856 cccccc F2 589 dddddd Result A B C d 1 Assembly aaaaaa bbbbbb cccccc 2 X 123 3 Z 123 4 A1 F002 5 Z2 F002 6 C3 456 7 D2 856 Regar...

Converting Borland C++ Project to MFC: Using CListCtrl vs CListView
I started this project attempting to keep it simple with the idea of using a ClistCtrl, but I am wonderng what I am missing and whether I should of used a CListView in instead. Basically, this old BC C++ GUI has a toolbar, a status line and a "list control" that holds 4 columns. Toolbar 4 column list control Status The conversion to MFC/ VC++ was long overdue and I started it this weekend. I used a MFC new project wizard with a SDI (Single Document Interface), a toolbar, etc. Doing nothing else, a compile and run has the tool bar and status control. It also create...

How do platform builder SDKs work?
Hi everyone. I have a question regarding SDKs on Windows CE 6 platform builder. I have 2 different boards based on the same BSP (Atmel AT91). On the first board (B47), I created a solution that builds the BSP and added an SDK call B47_SDK. Up till then, no problem. I can develop programs for this platform without issue. The problem is that I now I have a second board (B53). I created a solution that builds a BSP for this new board, and added an SDK called B53_SDK. If I install this new SDK, I can no longer develop applications for the B47 device. They seem to be mutually exclus...