According to the documentation, a boost::thread::id can be considered unique for each running thread and can be used in containers such as std::set and std::map (because the < operator is overridden for thread::id).
My problem is that I'd like to use thread::id as a key to an boost::unordered_map, however it requires that the key is "ha...
Silly question, but say you have class Foo:
class Foo
{
public:
typedef boost::shared_ptr<Foo> RcPtr;
void non_const_method() {}
void const_method() const {}
};
Having a const Foo::RcPtr doesn't prevent non-const methods from being invoked on the class, the following will compile:
#include <boost/shared_ptr.hpp>
int mai...
I don't understand the purpose of boost::checked_delete. The documentation says:
The C++ Standard allows, in 5.3.5/5,
pointers to incomplete class types to
be deleted with a delete-expression.
When the class has a non-trivial
destructor, or a class-specific
operator delete, the behavior is
undefined. Some compilers issue...
Hi,
I'm trying to build the boost regex example in eclipse using mingw on vista.
I built boost ok with mingw as there are library files XXXX.a.
I could build/compile the first boost example that doesnt require any of the compiled boost libraries.
When I compile the regex example I get a linker error saying it cant find the library file....
Using boost::serialization, what's the "best" way to serialize an object that contains cached, derived values in mutable members, such that cached members aren't serialized, but on deserialization, they are initialized the their appropriate default. A definition of "best" follows later, but first an example:
class Example
{
public:
...
I'm trying to serialize using boost property tree write_json, it saves everything as strings, it's not that data are wrong, but I need to cast them explicitly every time and I want to use them somewhere else. (like in python or other C++ json (non boost) library)
here is some sample code and what I get depending on locale:
boost::prope...
Hi,
I have a graph with custom properties to the vertices and edges. I now want to create a copy of this graph, but I don't want the vertices to be as complex as in the original. By this I mean that it would suffice that the vertices have the same indices (vertex_index_t) as they do in the original graph.
Instead of doing the copying by...
Since boost::shared_ptr could be called very frequently and simply returns a pointer, isn't the -> operator a good candidate for being inlined?
T * operator-> () const // never throws
{
BOOST_ASSERT(px != 0);
return px;
}
Would a good compiler automatically inline this anyway?
Should I lose any sleep over this? :-)
...
I cannot figure out why this segment gives unresolved overloaded function error (gcc version 4.3.4 (Debian 4.3.4-6)):
#include <algorithm>
#include <boost/function.hpp>
// this does not work
int main1()
{
typedef boost::function<const int&(const int&, const int&)> max;
max m(&std::max<int>);
}
// this does not work
int main2()...
Data may be read from or written to a
connected TCP socket using the
receive(), async_receive(), send() or
async_send() member functions.
However, as these could result in
short writes or reads, an application
will typically use the following
operations instead: read(),
async_read(), write() and
async_write().
I ...
Do we get multiple copies of the pointers yet the data members are still being shared?
boost::shared_ptr<string> a1(new string("Hello"));
vector<boost::shared_ptr<string> > a;
a.push_back(a1);
vector<boost::shared_ptr<string> > b;
b = a;
cout<<a[0]->c_str()<<b[0]->c_str()<<endl;
a1->append(" World");
cout<...
I have a program that I just changed to using a boost::multi_index_container collection. After I did that and tested my code in debug mode, I was feeling pretty good about myself.
However, then I compiled a release build with NDEBUG set, and the code crashed. Not immediately, but sometimes in single-threaded tests and often in multi-thr...
See this related question on more generic use of the Boost Random library.
My questions involves selecting a random element from an std::list, doing some operation, which could potentally include removing the element from the list, and then choosing another random element, until some condition is satisfied.
The boost code and for loop ...
Hello:
My job mostly consists of engineering analysis, but I find myself distributing code more and more frequently among my colleagues. A big pain is that not every user is proficient in the intricacies of compiling source code, and I cannot distribute executables.
I've been working with C++ using Boost, and the problem is that I cann...
A straight compilation of example http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/tutorial/tutdaytime3/src.html results in a runtime null pointer exception. Stack trace points to the buffer_debug_check destructor which contains this comment:
// MSVC's string iterator checking may crash in a std::string::iterator
// object's d...
Hi all,
I've created a class with a boost::unordered_map as a member,
Linkage.h
#ifndef LINKAGE_H
#define LINKAGE_H
#include <boost/unordered_map.hpp>
class Linkage
{
private:
boost::unordered_map<int, int> m_IOMap;
public:
....
};
Linkage.cpp
#include "stdafx.h"
... // methods
and in the managed side of C++,
I t...
Error in build BOOST.FIBER
"rule PYTON_IMPORT_RULE unknown in module pyutils",
boost build on Win
pyton will be installed
...
Is it allowed by the Boost License to just add the source code of the stuff I need to my project (accompanied by the license of course?). I couldn't find any "descriptive" confirmation. I would have seperate Include/boost and Source/boost directories for easy access.
PS: Seeing as boost::filesystem is going into C++0x TR2, and lambda, r...
I'm conflicted between a "read once, use memory+pointers to files" and a "read when necessary" approach. The latter is of course much easier (no additional classes needed to store the whole dir structure), but IMO it is slower? I'm trying to list the filenames and relative paths (so the compiler can do with them what it needs to).
A lit...
I know that boost or compiler should be last to blame, but I can't see another explanation here.
I'm using msvc 2008 SP1 and boost 1.43.
In the following code snippet execution never leaves third BOOST_FOREACH loop
typedef Graph<unsigned, unsigned>::VertexIterator Iter;
Graph<unsigned, unsigned> g;
g.createVertex(0x66);
// works fin...