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
2084 Views

Similar Articles

[PageSpeed] 22

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 (15974)
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 (3236)
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 (15974)
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 (15974)
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 (15974)
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 (15974)
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 (2060)
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 (15974)
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 (2060)
12/24/2008 12:26:49 AM
Reply:

Similar Artilces:

make chart based on equation
How can I make an excel chart based on an equation? On Fri, 10 Aug 2007, in microsoft.public.excel.charting, Daniel <Daniel@discussions.microsoft.com> said: >How can I make an excel chart based on an equation? Your equation will be in the form y=f(x). Create two columns, one of which is filled with values of x, and the other filled with copies of the equation f as an Excel formula, referring to the x values. Now make an XY Chart using these two columns. -- Del Cotter NB Personal replies to this post will send email to del@branta.demon.co.uk, which goes to a spam folder-- ...

Query/Report based on Employee Hire Date
This is probably a very basic thing that I just don't know how to do. I need to pull a report on people hired in December, regardless of year, for performance appraisals. The hire date that I currently have in the database is in the mm/dd/yyyy format. How do I sort on just the Month portion of this. I can then build my reports off of the query. Thank you in advance for any help or suggestions. Steve Add a calculated field to the query. Field: Month([Hire Date]) Criteria: 12 That gets everyone ever hired in the month of December. John Spencer Access MVP 2002-2005,...

Can I create a http based mail for outlook (like hotmail) in Xchg ?
Hi, Is it possible to create an http based mail to be received by outlook ? Just like what hotmail is providing, if I'm using MS Exchange server ? So, users can send/receive mail without using the POP3 port ? Any help appreciated ! ^-^ TIA Alex Oh, I don't wish OWA cos it's pure web only, I'm trying to formulate a solution for travellers to work offline, so they can download all emails to work locally even they're offline (on the road). POP3 would do the job, but many sites have firewalls to block that port, if I can use http (which most sites allow) then may ...

Create set based on column items feature in Pivot Tables 2010
I have a pivot table created in 2010 that I would like to use the 'create sets' feature in. However it is not enabled. The three 'sets' features are disabled as are the OLAP tools / What if analysis options on the Pivot Table options ribbon. What am i missing??? Cheers Julie Okay, found the problem - for 2010 the sets are only allowable for OLAP based Pivot Tables. :( On Nov 23, 10:16=A0am, jigsaw <jul...@consultant.com> wrote: > I have a pivot table created in 2010 that I would like to use the > 'create sets' feature in. =A0However it is not enabled....

Are Outlook On C-Drive
I'm saving a lot of my folders (emails) in my Archivefolder in MS Outlook using in internet email account (Hotmail) I can't access thhem through my Hotmail account anymore because I moved them into my archive folder. Other then through Outlook is tere any other way i can access these folders No, since they are now stored locally on your computer in a pst-file (mail database). You can see the linked location in; File-> Data File Management... If you would like to keep them on the server, you can move them back and disable AutoArchive; Tools-> Options-> tab O...

Add a .jpg to a cell so that it opens up when you hover over the c
I have a workbook of prices and descriptions of products and would like to add pictures (.jpg's) of the product so that when you hover over a cell the image would open so a salesperson could show a customer what the product looks like. If it could work like a "comment" it would be slick. Thanks, Steve Debra Dalgleish explains how to do it here: http://contextures.com/xlcomments02.html#Picture STEVE THE PARTS GUY wrote: > > I have a workbook of prices and descriptions of products and would like to add > pictures (.jpg's) of the product so that when you hover ove...

Printing a single record from a form based on a report's layout
Dear Friends? I feel plain stupid but I can't figure out to get my form to print a single record that is based off of my report. I am using Access 2003. Needless to say, I'm up against a deadline here and beyond frustrated. My table is called Advance2. My Form is called Onsite Form and my Report is called rptPrintRecord. Can you help? Jeff On 21 Apr 2007 20:32:37 -0700, LATorders@gmail.com wrote: > Dear Friends? > > I feel plain stupid but I can't figure out to get my form to print a > single record that is based off of my report. I am using Access > 2003...

Make checkboxes invisibile based on combo box selection
I'm working with Access 2007. I have a combo box on my form with three items to choose from in the drop down. I then have two check boxes that I want to be visibile only if the user selects the 2nd or 3rd item in the drop down. If they choose the first item in the drop down, I want the check boxes to disappear. I put my IF Statement in the combo box's AfterUpdate event. It works except that the checkboxes are either visibile or not visible in ALL of the records. How do I keep the checkboxes visible or invisible for each record? Not sure what I'm doing wrong. Bel...

How do I change Column names (a,b,c to Name, Number)
I am trying to change the Columns titles. Example, Column A becomes Column Name, Column B becomes Column, Address. That way when I'm working on row 57 I can still see which column the data goes in without having to scroll to the top and see which column is correct. I know I have done this before in a computer class, but not with the new Office systems. I think you are talking about Freeze Panes. Look it up in Help. With this you can freeze the column headers (your headers, not the A, B, C, etc) so that they will always be at the top of the screen no matter how far down y...

How can I copy values from one cell in a column down to the next c
How can I copy values from one cell in a column down to the next cell IF the 2nd cell is blank, For example: A1 = 20 B1 = I want the value of A1 to be copied to B1 if B1 is blank/contains a value of Null, I have about 11,000 records like this, where: If the next cell in the column is blank, then I need to copy the previous cells data into that cell. 2 ways: Easiest-If you click on A1 you should see a plus sign showing in the border at the bottom right. Click on that plus sign and hold down the mouse button while dragging down. Or-If the cell value increases by 1 at each row, then...

Adding T&C's to PO blank modified form (Report Writer)
What is the best way to add comany T&C's to the modified PO blank form? -- Regards, P Ebmeier Manager, Materials Systems GP 9.0 Purchase stock with the T&C's pre-printed on the back. Print your PO's on that stock. Frank Hamelly MCP-GP, MCT East Coast Dynamics www.eastcoast-dynamics.com Thank you for your suggestion. Most of our PO's are issued elecronically. I was just looking for a way to avoid sending two different docs (the PO and T&C's). -- Regards, P Ebmeier Manager, Materials Systems GP 9.0 "Frank Hamelly, MCP-GP" wrote: > Purc...

Need a Formula based on multiple cirteria
I am building a spreadsheet that will continue to grow in size. Th basic outline of the spreadsheet is as follows: A // B // C // D // E // F // G // H // I // J // K // Sys Name // Project // Type of Bldg // Type of Work // Type of Price / W/L // LNFT // CST // HRS // $/LNFT // HRs/LNFT // Consept of the sheet is: Column A will be grouped (using the Group command) Column B is input for reference only, no lookup functions need apply Column C is a Drop Down menu consisting of approximately 10 differen types of Bldg. Column D is a Drop Down menu consisting of approximately 5 differen types ...

Updating a field based on criteria
Hi, I had this before, but cant figure it out now. Say we have a database that has a RecordID(Primary), COLLARID(Multiple), LOCATION(NUMBERS), DATE, NOTES(text) Example... RecordID, COLLARID, LOCATION, DATE, NOTES 001,112,64.112X97.152,16/03/2010,BLANK 002,112,64.115X97.155,17/03/2010,BLANK 003,112,64.119X97.155,18/03/2010,BLANK 004,115,60.295X97.000,15/03/2010,BLANK 005,115,60.302X97.005,17/03/2010,BLANK 006,115,60.305X97.007,18/03/2010,BLANK As you can see above, the NOTES Field is all blank. What I hope to achieve is a function or query that will take a look at my dat...

"Cannot load GUI library into memory"
Does anyone know how I could eliminate the "Cannot load GUI library into Memory" warning upon creating a new istance of outlook? I am trying to automate some "overnight" emails from excel/access vba that requires outlook to be open. If not open, my excel vba opens a new instance of outlook. Unfortunately, upon doing so, i receive an Outlook 2007 warning pop-up stating "Cannot load GUI library into memory", effectively halting the procedure until the user clicks "ok". Any ideas as to how to either: 1) successfully direct Outlook 2007 t...

Insert Worksheets based on column data.
Hi everyone I run a report that creates a 7 coumn spreadsheet analysing staff time through a week. The last column (G) uses a staff code and is sorted in ascending order. What I would like to do is to run a macro or program that will go through the spreadsheet and create a new worksheet for each Staff code, naming the worksheet exactly the same, and inserting all the rows of data belonging to each staff code into its individual worksheet. For instance, if one of the Staff codes in the original pages is TW and there are 9 rows of data for TW, I would like a worksheet inser...

Conditonal Format based on two different criteria
Hi all. In column A I have a list of a bunch of different test names. In column D we have times associate with each test. I would like to make a conditional format that will check column A for a specific test name and then check to see if the time in column D meets a certain requirement. This is what I have tried but can't seem to get it to work. =AND($A$4="CBC",D$4$>.0416) Anyone got any ideas? It should work...make sure your time really is greater than 0.416, and not something like 0.41599999999 -- Best Regards, Luke M "Chad_Oglesbay" ...

Sum Number of Rows based on Value in Another Cell
Hi, Not sure that the subject line described what I want to do very well, I know that there is a long-winded way of doing what I want to do, but at the same time I know there must be a quicker and better way, so here goes. I'd like to to able to write a formula that will sum a number of rows, so as to create a 'year to date' column in my spreadsheet. I've put an example of what my worksheet contains below, and put simply I'd like the YTD column to be a sum of the values in column B, e.g. the YTD value for month 2 should be the sum of months 1&2, the Y...

Copy records automatically to another sheet based upon constant criteria
I have 1000+ address lines (name, address, phone) in a single sheet. I would like to make a copy, which will update, based upon constant criteria. Ex: I would like to copy all records which have 561 area code and place them on another sheet, all 856 on another and so on. Changes made to the "master" sheet would automatically update on the appropriate sheet - additions, changes, etc... Can anyone assist? Thank you in advance. On Jul 1, 8:41=A0am, skiing <trpa...@chatt.com> wrote: > I have 1000+ address lines (name, address, phone) in a single sheet. > I would like to mak...

Bug:V 9.00.281 Prints multiple 1099s for each vendor based on add.
Check 1099 print in v9.0.0281. It prints multiple 1099s for each vendor based on number of vendor addresses all for the same amount. It should only print one 1099 for each vendor to the primary address. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.micros...

media player library
I have lost my entire library of tunes. I have XP home edition, vers. 2002, sp3. I need to know the exact path to find where the library is stored. And once I get there what will it look like? A list? a mysterious bunch of data? or what? Please advise. "painter" wrote: > I have lost my entire library of tunes. I have XP home edition, vers. 2002, > sp3. I need to know the exact path to find where the library is stored. And > once I get there what will it look like? A list? a mysterious bunch of data? > or what? Please advise. On Mon, 7 Dec 2009 11:...

not receiving my email, rejecting my password. I am new p.c. user
New p.c. user, my email adress always same. I received many emails daily. Past several weeks, 0 email and Microsoft keeps rejecting yhe only password I ever used for everything. Someone please help me. brllpn94@centurytel.net <brllpn94@centurytel.net@discussions.microsoft.com> wrote: > New p.c. user, my email adress always same. I received many emails > daily. Past several weeks, 0 email and Microsoft keeps rejecting yhe > only password I ever used for everything. Someone please help me. Please include your verison of Outlook and Windows and the type of account you use (P...

Performance Issue with ownerdrawn controls in dialog based applica
Hello Everybody, I am using evc++ for creating multiple dialog based application with ownerdrawn button, edit and static labels for windows CE. Based on the input from user, i will launch the dialogs. Problem is that dialog creation takes time as all the controls are created in the OnInitDialog and each controls take a bitmap which again its a overhead as bitmap resources are very heavy. Is their any possiblity to create controls quickly so that all the controls are visible in short duration of time ? How to create controls if a dialog has more than 10 controls ? How to load jpeg, png f...

HTML to C++ events
Can anyone out there please provide an example of how I capture an event from a webpage, such as onclick or onkeypress and route it to a function within my c++ application. I'm really finding this difficult, although I realise this my be a little ambitious for someone who has only just started looking at COM. Thanks in advance. Martin there is an article in MSDN named "handling HTML element events". "Martin John Brindle" <martinbrindle@ntlworld.com> д���ʼ� news:P25Ce.731$Ox6.325@newsfe1-win.ntli.net... > Can anyone out there please provide an example...

using Outlook Object model from C#: App hangs when adding reciepients
Hi, I'm using the outlook library to send an email message through my asp.net application. The code that I'm using is similar to this: http://support.microsoft.com/default.aspx?id=310262 I've noticed while that my application hangs in this particular line. Can anybody give any insights ? Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients; Thanks in Advance, Bik >-----Original Message----- >Hi, >I'm using the outlook library to send an email message through my asp.net >application. The code that I'm using is similar to this: >http://supp...

structure of xml classes in C#
Hi I need to exchange XML formated information between two methods in my C# program. I have been trying to play with XMLNode and XMLElement but without much success. I think I want to stop now and understand the xml classes in C# (rather in dot net) before proceeding further. Can any one point me to such a resource ? Or even a primer on XML, which explains the definitions of nodes, elements and attributes ? Thanks. a.kamroot@gmail.com wrote: > I need to exchange XML formated information between two methods in my > C# program. I have been trying to play with XMLNode and XMLElement b...