Hello. I'm learning Boost::asio and all that async stuff. How can I asynchronously read to variable user_ of type std::string? Boost::asio::buffer(user_) works only with async_write(), but not with async_read(). It works with vector, so what is the reason for it not to work with string? Is there another way to do that besides declaring c...
I'm pretty new to programming and am generally confused by header files and includes. I would like help with an immediate compile problem and would appreciate general suggestions about cleaner, safer, slicker ways to write my code.
I'm currently repackaging a lot of code that used to be in main() into a Simulation class. I'm getting a c...
I'm having some trouble seeing what the best way to wrap a series of classes with Boost.Python while avoiding messy inheritance problems. Say I have the classes A, B, and C with the following structure:
struct A {
virtual void foo();
virtual void bar();
virtual void baz();
};
struct B : public A {
virtual void quux();
}...
I'm building the boost libraries with bjam for both the intel compiler and vs2008, and I can't tell what optimizations are being passed to the compiler from bjam. For one of the compiler's gcc, I can see some optimizations in one of the bjam files, but I can't find the optimization flags for the compilers I care about. So, my questions a...
I have a really short program written in boost::xpressive
#include <iostream>
#include <boost/xpressive/xpressive.hpp>
using namespace boost::xpressive;
int main()
{
std::string hello( "hello world!" );
sregex rex = sregex::compile( "(\\w+) (\\w+)!" );
smatch what;
if( regex_match( hello, what, rex ) )
{
...
It's common to declared contained objects as a pointers to that class, while "forward declarating" them in header file. This in order to reduce physical dependencies in code.
For example
class B; // forward declaration
class A {
private:
B* pB;
};
Would it be good idea to declare such a member as shared_ptr, instead of ...
I am using boost::thread to process messages in a queue.
When a first message comes I start a message processing thread.
When a second message comes I check if the message processing thread is done.
if it is done I start a new one
if it is not done I don nothing.
How do I know if the thread is done ? I tried with joinable() but it is ...
Hi all,
recently I've started to use the excellent boost::unordered_map on my system, but got one drawback: I couldn't figure how to inspect its contents. Printing it on gdb gives me a table_ and a buckets_, but haven't found where are the items. Anyone has a clue about this?
...
hello.
Is there preferred way to initialize (lazily) singleton data when using multiple threads from boost.threads?
Thanks.
...
Hi,
How to implement the ls "filename_[0-5][3-4]?" like class? The result I would like to store in the vector.
Currently I am using system() which is calling ls, but this is not portable under MS.
thanks,
Arman.
...
Hi all
I am trying to use boost::bind with a boost::function using this.
It seems a trivial example but I cannot make it work.Can you help me?
Is it because it is not allowed or am I doing something wrong?
Thanks afg
// .h
class MyClass{
publc:
void DoSomething(
const std::string& a,
const std::string& b);
vo...
Hi,
Sorry if this is a very basic questions for some of you but I'm new to C++ (let alone Boost Graph Library) and couldn't figure out this problem. So far I've been able to formulate/gather code to create a graph using the code below.
Now I'm trying to figure out the code to find the longest path in this graph.
Can someone please ...
I currently maintain a few boxes that house a loosely related cornucopia of coding projects, databases and repositories (ranging from a homebrew *nix distro to my class notes), maintained by myself and a few equally pasty-skinned nerdy friends (all of said cornucopia is stored in SVN).
The vast majority of our code is in C/C++/assembly ...
I've got two servers in active active configuration sharing a clustered database. One operation will be to tidy up the database (e.g. delete old records etc) which I only want one server to perform at a time.
I am currently planning on writing a configurable value into the dB so that one server can id if the other server is working on t...
Good day.
I'm trying to implement a question - answer logic using boost::asio.
On the Client I have:
void Send_Message()
{
....
boost::asio::async_write(server_socket, boost::asio::buffer(&Message, sizeof(Message)), boost::bind(&Client::Handle_Write_Message, this, boost::asio::placeholders::error));
...
I wrote a sparse vector class (see #1, #2.)
I would like to provide two kinds of iterators:
The first set, the regular iterators, can point any element, whether set or unset. If they are read from, they return either the set value or value_type(), if they are written to, they create the element and return the lvalue reference. Thus, ...
This is my code:
#include <string>
#include <boost/algorithm/string/regex.hpp>
string f(const string& s) {
using namespace boost::algorithm;
return replace_regex_copy(s, "\\w", "?");
}
This is what compiler says:
no matching function for call to ‘replace_regex_copy(const
std::basic_string<char, std::char_traits<char>,
std...
I'm running Ubuntu 8.04 and I ran the command:
$ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/stdlibcpp /usr/include/c++/4.2.4/
to generate a ctags database for the standard C++ library and STL ( libstdc++ ) on my system for use with the OmniCppComplete vim script. This gave me a very reasonable 4MB tags file which...
Can anyone tell what's going on here? When I try debug the code and when the control is in thread() function at Line 15, it skips over the Line 16 move to Line 17 and goes back Line 16. Why wouldn't it move Line by Line?
1. #include <boost/thread.hpp>
2. #include <iostream>
3.
4. void wait(int seconds)
5. {
6. boost::this_thread::...
hello.
A little bit of background: I have some strange multiple nested loops which I converted to flat work queue (basically collapse single index loops to single multi-index loop). right now each loop is hand coded.
I am trying to generalized approach to work with any bounds using lambda expressions:
For example:
// RANGE(i,I,N) is ...