boost::tuple has a get() member function used like this:
tuple<int, string, string> t(5, "foo", "bar");
cout << t.get<1>(); // outputs "foo"
It seems the C++0x std::tuple does not have this member function, and you have to instead use the non-member function form:
std::get<1>(t);
which to me looks uglier.
Is there any particular ...
I want to write a generic (C/C++) library that I will use to develop daemons in the Linux environment. Rather than reinventing the wheel, I thought I'd come in here to find out if there are any well known libraries in use.
The library could be either C or C++ - although I would prefer C++ (maybe something that was part of, or based on t...
Hello, I'm using boost (signals + bind) and c++ for passing function reference. Here is the code:
#define CONNECT(FunctionPointer) \
connect(bind(FunctionPointer, this, _1));
I use this like this:
class SomeClass {
void test1() {}
void test2(int someArg) {}
SomeClass() {
CONNECT(&SomeClass::test1);
CONNECT(&S...
#include <iostream>
#include <string>
#include <boost/bind.hpp>
void foo(std::string const& dummy)
{
std::cout << "Yo: " << dummy << std::endl;
}
int main()
{
int* test;
std::string bar("platypus");
(boost::bind(&foo, bar))(test, test, test, test, test, test, test, test);
}
When run, it prints out, "Yo: platypus." It...
Hello!
I am looking for some simple and efficient parameter container that would act like a in-memory-xml file representation (or ini-file, as another sample).
I mean, basically it could store sections and sets of parameters for each section, have easy accessors like GetValue("ParameterName") and simple return value casting.
It would ...
I am currently integrating an entity component system, as seen here, with a physics engine and a graphics engine. This was all fine until recently deciding that the physics should be running in its own thread. (Thanks Glenn Fiedler!)
As it is now I am simply locking a mutex shared by all subsystems when accessing components.
Snippet fr...
Using boost::program_options, I can not get my own option type to compile when it is declared inside a namespace. However outside of the workspace it compiles and works fine :
#include <boost/program_options.hpp>
using namespace boost;
using namespace boost::program_options;
struct my_type1 {
my_type1(int nn) : n(nn) {}
int n;
...
I'm using a fairly simple boost::asio set-up, where I call io_service.run() from the main thread.
I have a tcp resolver, and use async resolve to look up an address.
When that look-up fails, I throw an exception inside the asynchronous callback.
I catch this exception outside the run() call, inside the main function. I then call stop() o...
Ive got an application where I want to display a frame every x milliseconds.
Previously I did it like this:
class SomeClass
{
boost::thread thread_;
boost::timer timer_;
public:
SomeClass() : thread_([=]{Display();})
{
}
void Display
{
double wait = 1.0/fps*1000.0;
while(isRunning_...
Hello,
I am writing the following code on boost's program_options (version 1.42). This seems straight-forward and taken pretty much as is from the tutorial. However, I get a "multiple_occurrences" error. Further investigation discovers that it's (probably) the "filename" parameter that raises it.
The parameters I am giving are:
3 1 te...
My confuse is like this code:
#include "stdafx.h"
#include <boost/bind.hpp>
using namespace std;
void fool(std::string s)
{
std::cout<<s<<endl;
}
void fool2()
{
std::cout<<"test2 called\n"<<endl;
}
void fool3(std::string s1,std::string s2)
{
std::cout<<"test3 called\n"<<endl;
}
typedef boost::function<void(std::string)> myHandl...
I have a library which creates objects (instances of class A) and pass them to a python program which should be able to call their methods.
Basically I have C++ class instances and I want to use them from python. Occasionally that object should be passed back to C++ for some manipulations.
I created the following wrapper file (let's as...
This is the code to create a thread_group and execute all threads in parallel:
boost::thread_group group;
for (int i = 0; i < 15; ++i)
group.create_thread(aFunctionToExecute);
group.join_all();
This code will execute all threads at once. What I want to do is to execute them all but 4 maximum in parallel. When on is terminated, ano...
Hello,
I've some code that produces a set of tr1::array of different sizes, but same type, like
array<int, 2>
array<int, 4>
array<int, 6>
The number of these arrays, and their sizes, are given in compile time, so I know exactly how many of them there will be and how's big each one (but they may be different).
Problem: I would like to...
hello
I have been trying to generate doxygen documentation for boost, as a way to browse source tree and have man documentation.
However, doxygen has been running for past week or so on IBM power5, and I have no idea how much longer (right now I am on boost_1_43_0/boost/mpl/).
Is there prebuilt doxygen documentation, if not, is there a...
I am using boost serialization with xml files with a C++ program.
When I test my program in debug mode, it is working fine.
Then I try with the exact same file in release mode, but my program fails when loading the files. I even tried to generate the xml files with my program in release mode, load them back, and it crashes as well.
The...
I am trying to compile the multiple_sources.cpp to compile on my computer. I am running Xubuntu Lucid Lynx fully updated.
It will compile without issue with g++ -c multiple_sources.cpp but when I try to link and make an exectuable with g++ multiple_sources.o I get:
multiple_sources.cpp:(.text+0x3d): undefined reference to `boost::progr...
I wrote a program in c++ in VC++2008 with boost library for regular expression. But my code must be compiled in vc++6.0 compiler. vc++6 has compile error when using regular expression(I'm not actually sure but I can't compile boostRegex in vc++6).
So, for changing my library from boost, what is your opinion to me(one that is more simila...
Hello, I added to c++ includes path to my folder with boost, but even example code from official site, dont work. Should I do smth else? I have got:
boost/lambda/lambda.hpp: No such file or directory.
EDIT: In Code Blocks I set "settings->compiler and debugger->search directories->compiler" to path to `/boost/.
...
I really like the online STL documentation provided by http://www.cplusplus.com/.
Separately, I use some of the TR1 extensions via their Boost implementations.
I would like to find TR1 documentation online which is as good as the standard STL documentation provided by cplusplus.com. I'm especially interested in smart pointers and th...