boost

Boost bind function

Hi, I have a abstract base class A and a set of 10 derived classes. The infix operator is overloaded in all of the derived classes class A{ public: void printNode( std::ostream& os ) { this->printNode_p(); } protected: virtual void printNode_p( std::ostream& os ) { os << (*this); } };...

Code reading: where can I read great, modern, and well-documented C++ code?

Reading code is one of the best ways to learn new idioms, tricks, and techniques. Sadly it's very common to find badly written C++ code. Some use C++ as if it was C, others as if it was Java, some just shoot in their feet. I believe gtkmm is a good example of C++ design, but a binding could not be the best code to read (you need to kn...

boost::program_options bug or feature?

Very simple example: #include <string> #include <boost/program_options.hpp> namespace po = boost::program_options; int main(int argc, char* argv[]) { po::options_description recipients("Recipient(s)"); recipients.add_options() ("csv", po::value<std::string>(), "" ) ("csv_name", po::value<unsi...

What are the advantages and disadvantages of using boost::iterator_facade?

Yep -- the title pretty much sums it up. I've got quite a few types that implement iterator concepts, and I'm wondering if it's worthwhile to pull in this boost header instead of implementing things manually. So far: Advantages Well specified Less likely to have bugs ...

Can I use boost::make_shared with a private constructor?

Consider the following: class DirectoryIterator; namespace detail { class FileDataProxy; class DirectoryIteratorImpl { friend class DirectoryIterator; friend class FileDataProxy; WIN32_FIND_DATAW currentData; HANDLE hFind; std::wstring root; DirectoryIteratorImpl(); ...

Boost Asio Problem :/

Hey i'm trying to make some simple Network programs with Boost.Asio, this is my TCPClient class and i get some errors while compiling. But i don't know what is wrong :/ Thank you for your Help Regards. Code:http://pastebin.org/140001 Error:http://pastebin.org/139993 :) :) ...

Help with C++ Boost::regex

Hello everybody, I'm trying to get all words inside a string using Boost::regex in C++. Here's my input : "Hello there | network - bla bla hoho" using this code : regex rgx("[a-z]+",boost::regex::perl|boost::regex::icase); regex_search(input, result, rgx); for(unsigned int j=0; j<result.size(); ++j) ...

How to use C++ Boost's regex_iterator()

Hello, I'm using boost library to match substrings in a text. to iterate over results i need to use regex_iterator (see http://www.boost.org/doc/libs/1_42_0/libs/regex/doc/html/boost_regex/ref/regex_iterator.html) that's the only usage example i have found, but it's not clear for me (i don't understand the callback). could someone fa...

C++ allocators, specifically passing constructor arguments to objects allocated with boost::interprocess::cached_adaptive_pool

This is an embarrassing question, but even the well-written documentation provided with boost.interprocess hasn't been enough for me to figure out how to do this. What I have is a cached_adaptive_pool allocator instance, and I want to use it to construct an object, passing along constructor parameters: struct Test { Test(float argume...

What's correct way to remove a boost::shared_ptr from a list?

I have a std::list of boost::shared_ptr<T> and I want to remove an item from it but I only have a pointer of type T* which matches one of the items in the list. However I cant use myList.remove( tPtr ) I'm guessing because shared_ptr does not implement == for its template argument type. My immediate thought was to try myList.remove( sh...

Wrapping allocated output parameters with a scoped_ptr/array

So, I have some code which looks like this: byte* ar; foo(ar) // Allocates a new[] byte array for ar ... delete[] ar; To make this safer, I used a scoped_array: byte* arRaw; scoped_array<byte> ar; foo(arRaw); ar.reset(arRaw); ... // No delete[] The question is, Is there any existing way to do this using just the scoped_array, with...

boost object_pool construct method

I'm keen on using boost's object_pool class for memory re-use for a set of video frames. boost::object_pool< VideoFrame > FramePool; Now, the VideoFrame class has two constructors. The first version of the constructor takes 4 arguments while the second version takes 6 arguments/parameters. For every "new" video frame that is allocat...

"Unhandled exception" error when mixing boost::thread with wxWidgets GUI.

Hello there, I was trying to access a wxDialog members from a boost::thread: void AnotherThread(myWxDialog *dlg) { wxMessageBox(dlg->TextBox1->GetValue(), "It works!"); // This throws an error } void myWxDialog::OnButtonClick(wxCommandEvent &event) { boost::thread myThread(AnotherThread, this); } And I got this error: Unhandled...

Making an asynchronous Client with boost::asio

Hello, i'm trying to make an asynchronous Client with boost::asio, i use the daytime asynchronous Server(in the tutorial). However sometimes the Client don't receive the Message, sometimes it do :O I'm sorry if this is too much Code, but i don't know what's wrong :/ Client: #include <iostream> #include <stdio.h> #include <ostream> ...

Autoconf macro for Boost MPI?

I'm searching an autoconf macro to use in my configure.ac that checks for Boost MPI. It's not hard to find a couple of them on the Internet but none of the one I tried worked as expected. What ax_boost_mpi.m4 do you use? EDIT: I'll explain my requirement better. I need the macro to tell me if Boost MPI is available or not (defining HA...

Boost Thread Hanging on _endthreadex

I think I am making a simple mistake, but since I noticed there are many boost experts here, I thought I would ask for help. I am trying to use boost threads(1_40) on windows xp. The main program loads a dll, starts the thread like so (note this is not in a class, the static does not mean static to a class but private to the file). ...

Mocking with Boost::Test

Hello everyone :) I'm using the Boost::Test library for unit testing, and I've in general been hacking up my own mocking solutions that look something like this: //In header for clients struct RealFindFirstFile { static HANDLE FindFirst(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) { return FindFirstFile(lpFileName...

Compilation error when using boost serialization library

I have been struggling with this error for a long time. The following is my code snippet. //This is the header file template<typename TElem> class ArrayList { public: /** An accessible typedef for the elements in the array. */ typedef TElem Elem; friend class boost::serialization::access; template<class Archive> void se...

boost ublas: rotate 2d vector

Erm. I hope I am seriously overlooking something. I want to rotate a 2d vector (kartesian) v by a certain angle phi. I can't find a function that generates the appropriate matrix or just performs that function. I know how to do this by hand. I am looking for a ublas utility "something" that does this for me. ...

Containers of reference_wrappers (comparison operators required?)

If you use stl containers together with reference_wrappers of POD types, code such as the following works just fine: int i = 0; std::vector< boost::reference_wrapper<int> > is; is.push_back(boost::ref(i)); std::cout << (std::find(is.begin(),is.end(),i)!=is.end()) << std::endl; However, if you use non-POD types like (contrived example)...