Use often:
Various smart pointers
lambda
bind
function
noncopyable
date & time stuff
thread
lexical_cast
sometimes:
variant
filesystem
program_options
regex
Boost really is amazing, & it really surprises me how many fellow programmers haven't heard of it, or don't use it (although most that don't use Boost rarely use the STL (or.. properly anyways) either). Guess I'm still in uni though so probably a limited exposure.
Boost, what do you use it for?
Boost has many useful functions but almost all of them can be done without it.
Remember Codeka is my alternate account, just remember that!
All of them can be done without it. The point behind boost is to gather together useful stuff so you don't have to be the hundred thousandth person to reinvent the reference counted smart pointer.
Quote: Original post by CodaKiller
Boost has many useful functions but almost all of them can be done without it.
How about the STL? Let's re-invent that too! How about not bothering to use C++.. just use ASM. Or hell, let's just manually write the opcodes directly into the binary we want.
I fail to see your point.
At home I'm using a lot of bind and function to do callbacks/events. Pool is handy for organising all your memory allocations without having to use placement new yourself.
The main reason I don't use more is simply because I haven't explored much of the library yet -- usually threads like this one usually spur me on to look up a new feature (I've got some hand-rolled code that lexical_cast could replace, come to think of it).
Other parts I don't use because I'd already written/tested a home-made version, or had slightly different requirements (e.g. thread-local reference counted pointers).
I wish I could use it professionally... but that's not going to happen before using the STL / C++ standard library catches on around these parts :/
The main reason I don't use more is simply because I haven't explored much of the library yet -- usually threads like this one usually spur me on to look up a new feature (I've got some hand-rolled code that lexical_cast could replace, come to think of it).
Other parts I don't use because I'd already written/tested a home-made version, or had slightly different requirements (e.g. thread-local reference counted pointers).
I wish I could use it professionally... but that's not going to happen before using the STL / C++ standard library catches on around these parts :/
. 22 Racing Series .
Quote: Original post by diablos_blade
I was first introduced to boost as part of my University course, boost function was used fairly extensively in the Library the tutor had written as a basis for one of my modules.
But the reasons I first used it in any personal projects was for shared_ptr. Since then I've adopted a few other random bits and pieces into my project:
- function
- bind (pretty much solely as member function bind with boost::function, although has been useful for custom deleters with shared_ptr)
- noncopyable (you're right, I could write it myself, but it was already there)
- date_time
- string_algorithms
- filesystem
- variant
- unordered containers
- intrusive containers
Future plans:
- thread
- pool
As for examples of use.
variant: GLSL shader parameter values. I don't know how well you know openGL or GLSL but you can pass several different types of object into a shader. I decided to treat all of these the same, and store the data in a variant. The visitor pattern works perfectly for this, and the only other solution I could think of was inheritance. So this was a case where I just decided to experiment.
shared_ptr: Personally I use it for pretty much every pointer. But you might not like that. Something you might like though is automatic graphics resource management.
I have a central repository of resources (textures, shaders, meshes etc.) in my game. When a resource is allocated a shared_ptr is created with a custom delete function, a weak_ptr is stored in the repository and the shared_ptr is returned to the game. When that shared_ptr is no longer referenced it will call the custom delete function I provided which will remove it from the repository and free the resource. The reason for storing the weak_ptr in the repository is so that if the game tries to load the same resource more than once, I can get the shared_ptr from the weak_ptr and return that instead of loading the resource again and creating a new shared_ptr.
Having said all of that. If you really don't think you need boost. Then don't use it. But technically no one really needs anything in boost, it just make our lives a hell of a lot easier [grin]
I think you asnwered the question i should have asked. And that is, what do you use boost for in a gaming enviroment. :)
But in reply to your reply. I have also implemented resource loading systems, (texture, mesh, audio etc etc) and I had thought of implementing the system you suggested with shared pointers, but i can came to the conclusion, that i wouldnt be deleting or reallocting on the fly. Id simply load all my data to begin with, and clear anything i dont need or load new stuff, in specially predefined places, such as end of levels or checkpoints. But i still use a reference counting system, so that i dont load data more than once.
The reason im not using share_ptr is becuase i dont want it to automatically delete, i want the references to just drop to zero, and then be unloaded upon the end of the level or checkpoint.
When i say this, i mean large items, such as meshes or textures, that could cause noticable lag by being dynamically loaded. To be honest, with my game being so simple i doubt it would cause much of a problem, but im just trying to stick to techniques that i have been recommended or adviced from books and forums.
Quote: Original post by curtmax_0Quote: Original post by CodaKiller
Boost has many useful functions but almost all of them can be done without it.
How about the STL? Let's re-invent that too! How about not bothering to use C++.. just use ASM. Or hell, let's just manually write the opcodes directly into the binary we want.
I fail to see your point.
Your logic is flawed, you are taking it to a completely different level, anything in boost can be done with very little effect but the advantage of boost is that everything is in one place.
Remember Codeka is my alternate account, just remember that!
Quote: Original post by SiCrane
What do you mean by "very little effect"?
My guess is "very little effort".
I don't use boost, I tried it, but I didn't take advantage of it as much as I hoped too. The most useful part of boost to me was boost::function and boost::bind (managed to get compiler crashes with em), but I've rolled my own implementation of those with little effort now. If I was still using boost I think the things I'd use most of all:
* boost::function & boost::bind
* boost::signal
* boost::python
* boost::lexical_cast
Adventures of a Pro & Hobby Games Programmer - http://neilo-gd.blogspot.com/Twitter - http://twitter.com/neilogd
Quote: Original post by Richy2kQuote: Original post by SiCrane
What do you mean by "very little effect"?
My guess is "very little effort".
I don't use boost, I tried it, but I didn't take advantage of it as much as I hoped too. The most useful part of boost to me was boost::function and boost::bind (managed to get compiler crashes with em), but I've rolled my own implementation of those with little effort now. If I was still using boost I think the things I'd use most of all:
* boost::function & boost::bind
* boost::signal
* boost::python
* boost::lexical_cast
Yeah thats what I mean, sorry.
Remember Codeka is my alternate account, just remember that!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement