How much of Boost do you use?

Started by
20 comments, last by Dynamo_Maestro 10 years, 11 months ago
I needed a certain kind of library and saw one of Boost's libraries recommended over and over, so I've began installing Boost.
Having Boost has led me to thinking about all the other libraries in Boost I could be using. Like replacing all my maps with unordered_maps and replacing all my iterator-based for lines with foreach. It's a bit overwhelming since Boost introduces so many attractive features, but I have to learn its libraries first and also figure out where they fit into my existing code.
"Boostifying" a project would probably be impractical if it has a deadline or is made by a team, so I'm asking more from the perspective of an individual hobbyist developer.
So to all of those whose projects depend on Boost, how much of its libraries do you actually use?
Advertisement
quite alot of the stuff found in boost is available in C++11 so i don't use boost at all.

Both foreach loops(or range based for loops rather) and unordered maps are part of the standard now.

look at std::unordered_map

foreach loops are written as:

std::vector<int> somevector;

for(int x: somevector) {
dostuffwithxhere;
}
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

I'm still using boost smart pointers, but it's on my todo to replace them with the C++11 ones.

Also, one part of my code uses boost::hash, but I plan to replace that with std::hash.

I've moved away from boost's assert as well, since I have my own assert code.

Other than that, I'm still using boost::filesystem, and recently needed to (unfortunately) add boost::any.

Since a number of the common parts of boost hade it into TR1 and C++11, I use it a lot less.

Still, I'm using boost::filesystem a fair bit, and boost::spirit for a number of complex parsing tasks.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Boost has some nice items which I have used in the past but many of them have been moved to C++11 as Simon mentions above. For a game I generally try to avoid external dependencies as much as possible but things like: Boost serialization, ASIO and filesystem are pretty tempting when you need something to get a job done. Of course there are other standalone libraries which can be used instead, some of them are preferable in some ways also. It is really all a case of what you need, what your environment is like etc. Some examples:

ASIO- far beyond networking, I've used it to write daemonized multicore event driven data processing systems that were freaky scary but thanks to the ASIO framework it was just a matter of plugging in some custom event sources and then the processing code.

Serialization- well, I prefer a stand alone library I found but when you are in a hurry and can't sit down to write a custom serialization system it is a good enough stand in.

Filesystem- easy enough to replace, but time consuming. I wish this had made it to C++11 but it didn't, so do it yourself of use Boost.

Most of the other libraries are more special case and in many ways not really that useful. Exceptions such as context and others exist but are specialized to certain needs, signals(2) is something nice looking but for UI I use QT and would be unlikely to use signals in a game engine as I generally refer immediate mode UI's instead of retained.

Anyway, it is dependent on your needs at any given time if Boost is justified.

Im not running C++11 so theres a few libraries Im using ontop of my head and loving:

Serialization: I use this for loading/saving my custom asset files. Extremely easy to serialize/deserialize nested structs of data, and amazingly supports all the stl containers. The only downside is that it is NOT a header-only lib sad.png

Foreach: simple and I love the syntax. Awesome.

Bind/function: I use this for registering user callbacks for my input module.

Hash: I have scenes, nodes, meshes, etc reffered by name and I match them by the hashed names

I guess C++11 would have the greatest impact on how much of Boost I'd use.

I'm not running C++11 myself. At least, I don't think I'm running C++11 (using Mac OS X 10.6.8, Xcode 3.2.6, gcc 4.2.1). Given that I want to eventually support Windows, Mac, and maybe iOS, is C++11 supported in enough compilers to be used for production code?

I'm specifically getting Boost for signals(2) which I'll need for my UI code and for certain other things that need to generate events. For example, I want to be able to attach events to specific frames of animation objects. I'll probably also start using unordered_map since I have a lot of things I keep in maps and refer to by string IDs, and I don't need the sorting.

At least, I don't think I'm running C++11 (using Mac OS X 10.6.8, Xcode 3.2.6, gcc 4.2.1).

You have C++11 available. I don't believe it is enabled by default, though.

Given that I want to eventually support Windows, Mac, and maybe iOS, is C++11 supported in enough compilers to be used for production code?

Large parts of it, yes.

Mac, Linux and iOS have pretty solid support. Microsoft is a little more shaky, but gradually getting there (and you can use a recent version of GCC via MinGW instead).

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

At least, I don't think I'm running C++11 (using Mac OS X 10.6.8, Xcode 3.2.6, gcc 4.2.1).

You have C++11 available. I don't believe it is enabled by default, though.

I spent a while in the CMake articles making sure it is enabled, by default it is not. As a note though, I'd be curious why you have not updated to the newer Xcode? The transition to Clang is quite worth it, faster compiles usually and usually considerably better code generation.


At least, I don't think I'm running C++11 (using Mac OS X 10.6.8, Xcode 3.2.6, gcc 4.2.1).

You have C++11 available. I don't believe it is enabled by default, though.


GCC 4.2.1 is pretty old, isn't it? It seems most C++11 features began in gcc 4.3, and only really started getting the cool features around 4.5.

No, it's not enabled by default. You'd have to pass -std=c++0x to the compiler. Once you get to version 4.6 or so, you pass -std=c++11 instead.

Given that I want to eventually support Windows, Mac, and maybe iOS, is C++11 supported in enough compilers to be used for production code

Yep. GCC (and MinGW on Windows) implements the vast majority of the C++11 features, and most of the new standard library as well. I've only ran into one part of the C++11 standard library that wasn't available yet (the regex library) but even that might've been added in recent versions.

It's stable and supported well in Max, Linux, and Windows. I don't know about iOS.

This topic is closed to new replies.

Advertisement