Hello!
What are the advantages of using boost.any library ? Could you please give me some real life examples ? Why the same functionality couldn't be achieved by having some generic type in the root of object's hierarchy and creating containers with that base type ?
...
The problem is pretty basic.
(I am puzzled why the search didn't find anything)
I have a rectangular "picture" that stores it's pixel color line
after line in a std::vector
I want to copy a rectangular region out of that picture.
How would I elegantly code this in c++?
My first try:
template <class T> std::vector<T> copyRectFr...
Hi,
I need to share a stack of strings between processes (possibly more complex objects in the future). I've decided to use boost::interprocess but I can't get it to work. I'm sure it's because I'm not understanding something. I followed their example, but I would really appreciate it if someone with experience with using that library...
Hi all,
I use boost.test library to write unit tests for my application.
The problem is, when one particular *.cpp file containing test suite grows up to certain size, compilation of that file becomes extremely slow.
I use BOOST_AUTO_TEST_CASE macro to define test cases.
Boost version is 1.34.1
Build env is autotools + gcc 4.3 under...
I'm thinking about serializing data in an application which is Qt-based.
Essentially what I'm going to serialize is my hierarchical model, which is composed of different classes that derive from, say, TreeModelItem:
class TreeModelItem
{
protected:
QList<TreeModelItem *> m_children;
//...
};
Should I study boost::serialization an...
Hi
I`m writing a web spider and want to use boost regex library instead of crafting some complicated parsing functions.
I took a look at this example:
#include <string>
#include <map>
#include <boost/regex.hpp>
// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, ...
I'm trying to figure out how to wrap a boost::function member (used as an event callback) of an unmanaged class with a C++/CLI class event. I do not have control over the unmanaged class. All I can do is figure out how to write the C++/CLI class properly.
Here's the example unmanaged class:
class X
{
public:
boost::function<void ...
What do you think? Is this correct or are there memory leaks?
Source:
#include <QList.h>
#include <boost/shared_ptr.hpp>
#include <iostream>
class A {
private:
int m_data;
public:
A(int value=0) { m_data = value; }
~A() { std::cout << "destroying A(" << m_data << ")" << std::endl; }
operator int() const { return m_data...
I am passed an Iterator and I have to pass it on to another function -- but filtered so that certain elements are skipped (it's a range of pointers, and I want to filter out the NULL pointers).
I googled for "stl filter iterator" to see how to do this, and boost::filter_iterator came up.
That looks nice and I could use it, but could ...
I'm new to C++ and am writing a multi-threaded app whereby different writers will be pushing objects onto a stack and readers pulling them off the stack (or at least pushing the pointer to an object)..
Are there any structures built-into C++ which can handle this without adding locking code etc.? If not, what about the Boost libraries?
...
Hi
I'm trying to write a regular expression for my html parser.
I want to match a html tag with given attribute (eg. <div> with class="tab news selected" ) that contains one or more <a href> tags. The regexp should match the entire tag (from <div> to </div>). I always seem to get "memory exhausted" errors - my program probably takes ev...
I'd like to iterate over a std::map using BOOST_FOREACH and edit the values. I can't quite get it.
typedef std::pair<int, int> IdSizePair_t;
std::map<int,int> mmap;
mmap[1] = 1;
mmap[2] = 2;
mmap[3] = 3;
BOOST_FOREACH( IdSizePair_t i, mmap )
i.second++;
// mmap should contain {2,3,4} here
Of course this doesn't change anything...
The following code of mine compute
the confidence interval using Chi-square's 'quantile'
and probability function from Boost.
I am trying to implement this function as to avoid
dependency to Boost. Is there any resource where can I
find such implementation?
#include <boost/math/distributions/chi_squared.hpp>
#include <boost/cstdint.hpp...
I'm developing a C++ program which has a "scan" method which will trigger a relatively long running scanning procedure. When the procedure is completed, the scan method will notify observers of results using the observer pattern.
I would like to create a separate thread for each scan. This way I can run multiple scans simultaneously. W...
I'm running into some issues with boost::bind and creating threads.
Essentially, I would like to call a "scan" function on a "Scanner" object, using
bind.
Something like this:
Scanner scanner;
int id_to_scan = 1;
boost::thread thr1(boost::bind(&scanner::scan));
However, I'm getting tripped up on syntax. How do I pass the ...
I've recently managed to create a thread using the boost::bind function.
For the time being, I'm having the thread display to stdout. I can see the output if I use thread.join. However, if I don't do this, I don't see any output.
Why is this?
I'm hoping I don't have to use the join function, because I would like to call this functi...
Is there a single-expression way to assign a scalar to all elements of of a boost matrix or vector? I'm trying to find a more compact way of representing:
boost::numeric::ublas::c_vector<float, N> v;
for (size_t i=0; i<N; i++) {
v[i] = myScalar;
}
The following do not work:
boost::numeric::ublas::c_vector<float, N>
v(myScal...
I spent about 4 hours yesterday trying to fix this issue in my code. I simplified the problem to the example bellow.
The idea is to store a string in a stringstream ending with std::ends, then retrieve it later and compare it to the original string.
#include <sstream>
#include <iostream>
#include <string>
int main( int argc, char** ...
The following template will decide if T is abstract with g++.
/**
isAbstract<T>::result is 1 if T is abstract, 0 if otherwise.
*/
template<typename T>
class isAbstract
{
class No { };
class Yes { No no[3]; };
template<class U> static No test( U (*)[1] ); // not defined
template<class U> static Yes test( ... ); // not d...
Hi,
I'am trying to understand the example from program_options of the boost library (http://www.boost.org/doc/libs/1_38_0/doc/html/program_options/tutorial.html#id3761458)
Especially this part:
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
what exactly is he ...