boost

Prevent memory pollution in web application (boost::asio).

well, I read data to buffer using read_until - it's easy to check it's size after that. What about aborting reading after excesses some defined limit of package length? PS Also std::string s((istreambuf_iterator<char>(someStreamBuf)), istreambuf_iterator<char>()); Doesn't work properly - it cuts part of last line (everyth...

How do I get boost::condition::timed_wait to compile?

I want to wait on a condition for up to 1 second. I've try passing in time_duration: boost::posix_time::time_duration td = boost::posix_time::milliseconds(50); readerThread_cond_.timed_wait(lock, boost::bind(&XXXX::writeCondIsMet, this), td); but I get the error: /usr/include/boost/thread/pthread/condition_variable.hpp:156: erro...

Extract correct text from a wifstream regardless of encoding.

Here is the program: http://codepad.org/eyxunHotThe encoding of the file is UTF-8. I have a text file named "config.ini" with the following word in it: ➑ball If I use notepad to save the file with "UTF-8" encoding, then run the program, according to the debugger the value of eight_ball is: âball If I use notepad to save the file wi...

Distinguish between const and non-const method with same name in boost::bind

When I use boost::bind with a method name which is declared both const and non-const I am getting in ambiguous error, for example boost::bind( &boost::optional<T>::get, _1 ) How can I solve this problem? ...

Is there a way to find out whether a class is a direct base of another class?

Hi I'm wondering whether there is a way to find out whether a class is a direct base of another class i.e. in boost type trait terms a is_direct_base_of function. As far as I can see boost doesn't see to support this kind of functionality which leads me to think that its impossible with the current C++ standard. The reason I want it is...

binding to member variables

The following example from boost bind does not work for me: #include <boost/bind.hpp> struct A { int data; }; int main() { A a; boost::bind(&A::data, _1)(a) = 1; } error: assignment of read-only location 'boost::bind [with A1 = boost::arg<1>, M = int, T = A](&A::data, (<unnamed>::_1, boost::arg<1>())).boost::_bi::bind_t<...

Using boost.assign on collection of shared_ptr

Consider the following snippet: class Foo { public: Foo( int Value ); // other stuff }; std::list< boost::shared_ptr< Foo > > ListOfFoo = list_of( 1 )( 2 )( 3 )( 4 )( 5 ); This does not work out of the box. What is the simplest way to make this work, or is there any method to assign values to ListOfFoo as simple as that? ...

How do I troubleshoot boost library/header inclusion via autoconf/automake?

I'm new to autom4te, and I'm trying to use autoconf/automake to build and link a C++ program on multiple architectures. Complicating the linking is the fact that the project requires boost (filesystem, system, program_options). I'm using boost.m4 (from http://github.com/tsuna/boost.m4/tree/), and it seems to locate all the libraries and...

boost::filesystem::create_directories(); adding folders to strange locations

I'm using boost to create a directory to place some temp files in. int main( int argc, char* argv[] ) { std::cout << "Current Dir: " << argv[0] << std::endl; boost::filesystem::create_directories( "TempFolder" ); return 0; } Now if double click the exe, the folder "TempFolder" is created in the same directory as the exe, ...

Correct BOOST_FOREACH usage?

When using BOOST_FOREACH, is the following code safe? BOOST_FOREACH (const std::string& str, getStrings()) { ... } ... std::vector<std::string> getStrings() { std::vector<std::string> strings; strings.push_back("Foo"); ... return strings; } Or should I grab a copy of the container before calling BOOST_FOREACH, e.g.: cons...

Cant compile Boost C++ Network Library 0.5

Boost Network I am trying out this code in a small console app on windows (VS2008) but cant compile it. Have linked to the boost.system library. Am i missing a header, #define or another library? Headers #include <boost/network/protocol/http/client.hpp> #include <iostream> Errors using native typeof 1>c:\dev\3rdparty\boostproposed...

Creating a prefixed sequence in one line

Given the initialized variables unsigned a, unsigned b with b > a and std::vector<std::string> strings of size b-a. How can I fill strings with the elements e.g. "x3" "x4" "x5" "x6" (in case a=3 and b=7) for arbitrary a and b with one C++ command (meaning one semicolon at all :))? ...

Move C++ app with Boost from Linux to Windows with Visual Studio 6

I made a small program with Boost in Linux 2 yrs ago. Now I want to make it work in Windows. I found there are few .a files in my libs folder. I am wondering how to make it works in Windows? do I need to build Boost in Windows to get library or I can download somewhere? I am using Visual Studio 6. ...

boost::lock_guard vs boost::mutex::scoped_lock

Which is preferred boost::lock_guard or boost::mutex::scoped_lock? I'm using Boost.Thread with the hope to move to C++0x threading when it becomes available. Is scoped_lock part of the next c++ standard? Are the any advantages to prefer one over the other? NOTE: I'm aware that scoped_lock is just a typedef of lock_guard. edit:...

Releasing a boost::ptr_vector, not matching documentation

I'm using boost 1.37, and I'm trying to use a boost::ptr_vector, and transfer ownership of it so I can return it from a function. Looking at the boost documentation (http://www.boost.org/doc/libs/1_36_0/libs/ptr_container/doc/tutorial.html#new-functions) std::auto_ptr< boost::ptr_deque<animal> > get_zoo() { boost::ptr_deque<animal> ...

Boost c++ library install

I am not familiar with the usual build technique in linux I am using boost c++ library. Can any body guide me in installing and configuring boost c++ library. Thanks in advance ...

Adding boost::ptr_vector to deque, typeid mismatch

I'm trying to add a boost::ptr_vector to a std::deque, using push_back(). When I do, I get a BOOST::ASSERT for the typeid mismatch. In "boost_ptr_container_clone_allocator" T* res = new T( r ); BOOST_ASSERT( typeid(r) == typeid(*res) && "Default new_clone() sliced object!" ); return res; From TotalVi...

undefined reference to `boost::system::get_posix_category()'

g++ simple_wget.cpp -lssl -lboost_system -lpthread -lcrypto -lboost_filesystem /tmp/cc2jNHvk.o: In function `__static_initialization_and_destruction_0(int, int)': simple_wget.cpp:(.text+0x5eb): undefined reference to `boost::system::get_posix_category()' simple_wget.cpp:(.text+0x5f5): undefined reference to `boost::system::get_posix_cate...

Boost regular expressions

Does anyone know of any good tutorials on regular expressions using boost? I have been searching for a decent one, but it seems most are for people who know a little about regular expressions ...

ReadWrite lock using Boost.Threads (how to convert this simple class)

I am porting some code from windows to Linux (Ubuntu 9.10). I have a simple class (please see below), which uses windows functions to implement simple mutex locking. I want to use Boost.Threads to reimplement this, but that library is new to me. Can someone point out the changes I need to make to the class below, in order tomuse Boost.T...