PDA

View Full Version : Boost libraries



steg90
9th May 2007, 16:05
Hi,

I was wondering how many of you here use the Boost libraries with your Qt applications?

Regards,
Steve

jacek
9th May 2007, 21:01
I have added a poll, so that everybody can answer this question easily.

patrik08
10th May 2007, 13:52
Hi,
I was wondering how many of you here use the Boost libraries with your Qt applications?
Regards,
Steve


What is Boost libraries?
is this a way to become more source code line? I know only QT libs, curl, tidy, libxslt, libxml2, libexiv2 , Sablot XSLT, all lib wo can build on all OS...

my last discovery libs is http://poppler.freedesktop.org/ to transform pdf to image... but is not possibel to build if automake or autoconf is not the last version..

libraries wo is not possibel to build quick , not give sense to me. this is like to write a cin.getline from string and transform to QString

steg90
10th May 2007, 15:08
Hi,

Take a look at http://www.boost.org

Regards,
Steve

Brandybuck
14th May 2007, 20:11
I have used Boost, but it's cumbersome to use. It is a very "academic" library that is wholly unsuitable if you are not a C++ expert. It relishes in using all of the advanced features of C++, even for the simplest of problems. It is primarily based not on Object Oriented Programming, but Generic Programming. If you don't know what a functor is, stay away!

Most things that Boost gives you are already available in Qt.

Michiel
14th May 2007, 23:53
I have used Boost, but it's cumbersome to use. It is a very "academic" library that is wholly unsuitable if you are not a C++ expert. It relishes in using all of the advanced features of C++, even for the simplest of problems. It is primarily based not on Object Oriented Programming, but Generic Programming. If you don't know what a functor is, stay away!

Most things that Boost gives you are already available in Qt.

Yes, but I've found that you either use Qt all the way, or you don't use Qt. The Qt classes are very interdependent. Whereas boost is meant to be an extension of the standard library.

Brandybuck
15th May 2007, 00:32
The Qt classes are very interdependent. Whereas boost is meant to be an extension of the standard library.
Actually, Boost is quite interdependent as well. It's nearly impossible to take just one class (or set of related classes) out of Boost and use it by itself. And while some people are lobbying for parts of Boost to be included in a future C++ standard library, that does NOT mean Boost should be treated as a C++ standard.

steg90
15th May 2007, 08:38
I have noticed a lot of the financial trading software houses in the uk use Boost?!

Brandybuck
15th May 2007, 21:13
There's a lot of US financial trading companies in New York using Qt :-)

wysota
15th May 2007, 22:06
Especially if their software was written by ICS ;)

steg90
16th May 2007, 16:25
Pity I'm in the UK! I do know certain financial houses do use Boost here in the UK. I have 'played' with it in the past and used mainly the smart pointers as I often forget to delete pointers and using these, it does it for you :rolleyes:

wysota
16th May 2007, 17:42
Smart pointers delete objects? I think we're having a different concept of smart pointers... Mine is that it sets the pointer to 0 once the object pointed is deleted. The concept you described I'd call a hijacking pointer and I don't want my pointers hijacked :) Anyway: QPointer.

steg90
18th May 2007, 07:31
Hi,

Not heard of 'hijacking' pointer :p

I'll take a look at QPointer, thanks!

Regards,
Steve

wysota
18th May 2007, 09:37
It's hijacking, because when it's destroyed, it destroys the pointed object as well (that's what you said). This means that if it doesn't have ownership of the object, it'll hijack it from the real owner. And it's probably implemented more or less like so:

template <typename T> class HijackingPointer {
public:
HijackingPointer(T *ptr=0), m_ptr(ptr){}
void setPointer(T* ptr){ m_ptr = ptr; }
~HijackingPointer(){ delete m_ptr; }
// + operator T*, operator * and operator ->
private:
T* m_ptr;
};

I don't think I have to link to a bloated library just for this small snippet.

jacek
18th May 2007, 13:06
I don't think I have to link to a bloated library just for this small snippet.
std::auto_ptr from STL is the one that "hijacks" pointers, not the classes from Boost's Smart Pointers family.

wysota
18th May 2007, 18:20
So Boost pointers won't do that for you:

. I have 'played' with it in the past and used mainly the smart pointers as I often forget to delete pointers and using these, it does it for you.

Right?

jacek
18th May 2007, 20:04
So Boost pointers won't do that for you: [...] Right?
It depends which one you choose.

wysota
19th May 2007, 00:57
So is there a pointer in the family that deletes objects pointed to when it's deleted but doesn't hijack the object (for me this is contradictory, but maybe I just can't imagine the situation)?

jacek
19th May 2007, 02:58
So is there a pointer in the family that deletes objects pointed to when it's deleted but doesn't hijack the object (for me this is contradictory, but maybe I just can't imagine the situation)?
Boost has three kinds of smart pointers: shared pointers, which share the ownership amongs them,
scoped pointers, which take the ownership for themselves,
weak pointers, which don't take the ownership, but know when the object was destroyed.
All these three kinds of smart pointers are well behaved and the term "hijacking" isn't appropriate. It's just as if you said that QCoreApplication::postEvent() "hijacks" pointers, because it takes their ownership --- it doesn't, it's just a part of its contract.

If you want to call something "pointer hijacking", take a look what std::auto_ptrs do on copy --- they're like hungry hienas, which steal a dead antilope from each other.

wysota
19th May 2007, 08:54
So "weak pointer" is an equivalent of QPointer, "scoped pointer" does to pointers more or less what QMutexLocker does to mutexes and shared pointer is a combination of the two that does reference counting. Correct? Of course all these might fail if you use any regular pointers with the same object.

jacek
19th May 2007, 15:53
Correct?
Yes.


Of course all these might fail if you use any regular pointers with the same object.
Like everything which deals with pointers.

wysota
19th May 2007, 17:29
Like everything which deals with pointers.

But not QPointer :)

Michiel
19th May 2007, 17:40
But not QPointer :)

It's nothing to boast about if your smart pointer is restricted to QObject descendants. :p

kiker99
9th June 2007, 23:17
What I've tried from boost yet was just great. If you need to do parsing: Have a look at Boost.Spirit. It uses TMP (template meta programming) and gives C++ a completely new dimension :)

magland
10th June 2007, 03:43
For those who have successfully used boost libraries with Qt, I would be interested to learn about your experience... is it straightforward to integrate, and are there any packages or example projects using Qt with boost?

jacek
11th June 2007, 00:41
is it straightforward to integrate, and are there any packages or example projects using Qt with boost?
I haven't tried all of the boost classes, but so far I had no problems at all.

See this page: http://boost.org/doc/html/signals/s04.html#id1633734

spud
13th June 2007, 12:50
Most often it is very easy to use boost with Qt, since most of the libraries are header only libraries. You only have to download it and modify your include path. The only libraries which have to be compiled and linked to are(from http://www.boost.org/more/getting_started/windows.html#header-only-libraries):


Boost.Filesystem
Boost.IOStreams
Boost.ProgramOptions
Boost.Python (see the Boost.Python build documentation before building and installing it)
Boost.Regex
Boost.Serialization
Boost.Signals
Boost.Thread
Boost.Wave

and obviously most of these offer functionalities which normally you'd let Qt take care of. I've only used them for projects where I couldn't use Qt.