The below is from the official BOOST docs.
Why do I always get size of zero when calling region.get_size() ? What am I doing wrong?
int main(int argc, char *argv[])
{
//Create a native windows shared memory object.
windows_shared_memory shm (create_only, "MySharedMemory", read_write, 1000);
//Map the whole shared memory in this ...
I have a template that I would like to conditionally compile depending on the type of the argument. I only care about differentiating between "Plain Old Data" (POD), i.e., integers, etc or classes/structs. I'm using c++ VS2008 on Windows.
template<T>
class foo
{
void bar(T do_something){
#if IS_POD<T>
do something for ...
Hi,
In boost multi-index, can i verify whether a particular index type is ordered/not through meta programming?
There are the ordered indexes, hash indexes, sequence indexes etc. Can i find them out through meta programming?
suppose there is a index like
int main()
{
typedef multi_index_container<double> double_set;
r...
I'm learning the use of boost smart pointers but I'm a bit confused about a few situations.
Let's say I'm implementing a state machine where each state is implemented by a single update method.
Each state could return itself or create a new state object:
struct state
{
virtual state* update() = 0; // The point: I want to return a ...
I have written a class with protected constructor, so that new instances can only be produced with a static create() function which returns shared_ptr's to my class. To provide efficient allocation I'd like to use boost::make_shared inside the create function, however the compiler complains that my class constructor is protected inside b...
Free function allocate_shared can be used with any standard compliant allocator. But what about shared_ptr's constructor and reset method.
template<class Y, class D, class A> shared_ptr(Y * p, D d, A a);
template<class Y, class D, class A> void reset(Y * p, D d, A a);
The manual says that D should provide a call operator which will be...
I'm trying to determine whether or not a string contains a number. This doesn't seem to be working.
static const regex re("([0-9]+)");
cout << regex_match("L5", re);
prints
0
Thanks!!
...
Hi,
I have been trying to set the TTL on ICMP packets using the
boost::asio::ip::unicast::hops option (using Boost 1.43) and then reading it out with get_option.
get_option gets 1 regardless what I use in set_option. And when inspecting the
packets sent using wireshark, the TTL is 128. Am I missing something here?
Should I use another ...
Hi all,
I am using Boost.Python to extend python program functionality. Python scripts do a lot of calls to native modules so I am really concerned about the performance of python-to-cpp type conversion and data marshaling.
I decided to try exposing methods natively through Python C API. May be somebody already tried that before ? Any ...
Hi, i would like to serialize a class with an attribute as a list of pointers on a generic class
This is the parent class from which the generic class derives :
class Base{
public :
friend class boost::serialization::access;
virtual ~Base(){}
template<class Archive>
void serialize(Archive & ar, ...
I'm writing a program for Linux in C++, and I need to store some additional data, such as images. Stuff like that is usually in /usr/share on Linux.
The user can decide where to install the software (I'm using CMake), thus I should either use /usr/share, /usr/local/share, /home/theuser/somefolder/share or whatever, depending on where he...
* glibc detected malloc(): memory corruption (fast): **
This is the error I get when, in a multithreaded environment, I execute this portion of code:
/// Some declarations
typedef boost::shared_ptr<Object> ObjectPtr;
ObjectPtr getObject()
{
return ObjectPtr(new Object);
}
/// What is actually executed in a thread
void executeWor...
Note: This may sound dumb.
I have an application which uses raw pointers and there are lots of memory leaks in the application.
Now my question is how easy would it be to replace the existing raw pointers with the smart pointers.
And would just replacing them help is reducing memory leaks caused by not freeing dynamically allocated mem...
In boost::numeric::ublas, there are three sparse vector types.
I can see that the mapped_vector is essentially an stl::map from index to value, which considers all not-found values to be 0 (or whatever is the common value).
But the documentation is sparse (ha ha) on information about compressed_vector and coordinate_vector.
Is anyone ...
Maybe I'm not all there today, but I'm wondering how to get this to work.
I'd like to partially specialize range_mutable_iterator and range_const_iterator from the boost library but only for specific types that I'd rather avoid mentioning explicitly, instead only letting the partial specialization be chosen if the enable_if test criteria...
I have to register an object in a container upon its creation.
Without smart pointers I'd use something like this:
a_class::a_class()
{
register_somewhere(this);
}
With smart pointers I should use shared_from_this but I can't use that in the constructor.
Is there a clean way to solve this problem? What would you do in a similar s...
Are there precompiled .libs for boost on 64 bit VC++ 2010?
...
I'm using boost::filesystem to rename a file like this:
boost::filesystem::rename(tmpFileName, targetFile);
tmpFileName / targetFile are of type boost::filsystem::path.
While doing this, I iterate over the directory using this code in another thread:
directory_iterator end_itr;
for (directory_iterator itr(dirInfoPath); itr != end_i...
I would like to parallelize my boost random number generator code in C++ with OpenMP. I'd like to do it in way that is both efficient and thread safe. Can someone give me pointers on how this is done? I am currently enclosing what I have below; this is clearly not thread safe since the static variable in the sampleNormal function is like...
Is it better to use boost::asio::basic_stream_socket::async_read_some instead of boost::asio::async_read when it comes to high performance data throughput?
...