boost

Equal sign in Boost RegEx

Hello all, I've got a problem with the following Boost regular expression, boost::regex e("="); if(regex_search("=", e)) cout << "yeah"; Can anybody please tell me why I don't get a "yeah"? This is Boost 1.37 with Visual Studio 2008. Thank you very much in advance! ...

regular expression to split up searchphrase

I was hoping someone could help me writing a regex for c++ that matches words in a searchphrase, and explain it bit by bit for learning purposes. What I need is a regex that matches string within " " like "Hello you all", and single words that starts/ends with * like *ack / overfl*. For the quote part I have \"[\^\\s][\^\"]*\" but I c...

parser: parsing formulas in template files

I will first describe the problem and then what I currently look at, in terms of libraries. In my application, we have a set of variables that are always available. For example: TOTAL_ITEMS, PRICE, CONTRACTS, ETC (we have around 15 of them). A clients of the application would like to have certain calculations performed and displayed,...

change boost thread priority

Im trying to change the thread priority in boost but im having no luck. Im getting a bad handle error (type 6) from the GetLastError function. I though native_handle() returned the handle for the thread? Any one know how to do this? void baseThread::applyPriority(uint8 priority) { #ifdef WIN32 if (!m_pThread) return; BOO...

How to get IP addresss of boost::asio::ip::tcp::socket?

Hello, I'm writing a server in C++ using Boost ASIO library. I'd like to get the string representation of client IP to be shown in my server's logs. Does anyone know how to do it? ...

How do I get access to state machine object from fifo_scheduler?

I'm using boost statechart libary to implement a state machine. I have created a state machine derived from asynchronous_state_machine and using it with fifo_scheduler as explained in the example in http://www.boost.org/doc/libs/1_38_0/libs/statechart/doc/tutorial.html#AsynchronousStateMachines. Since the state machine object is created...

C++ Assertions that Can Display a Custom String with Boost or STL?

Hi, I really want to be able to go: (in C++) assert( num > 0, "The number must be greater than zero!"); In C# XNA, they have a method that does exactly this: Debug.Assert( num > 0, "The number must be greater than zero!"); Is there some way to do this so that the runtime gives me a meaning full error not just "an assertion failed" ...

Boost adjacency_list help needed

I'm trying to use Boost's adjacency_list type and I'm having trouble understanding the documentation. Say I define a class named State and I instantiate one instance for each state in the USA: class State { ... }; State california, oregon, nevada, arizona, hawaii, ... I want to enter these into a boost::adjacency_list the vertices ar...

I need to create a simple callback in c++? Should I use boost::function?

Suppose I have some code like this: class Visitor { public: Visitor(callBackFunction) {} void visit() { //do something useful invokeCallback(); } } class ClassThatCanBeVisited { Visitor &visitor; public: ClassThatCanBeVisited(Visitor &_visitor) : visitor(_visitor){} void s...

"Unable to start program" (Debug build)

Microsoft Visual Studio Unable to start program 'theprogram.exe'. This application has failed to start because the application configuration is incorrect. Review the manifest file for possible errors. Reinstalling the application may fix this problem. For more details, please see the application event log. O...

Copy-on-write with shared_ptr when multithreading

In the absence of multithreading, the implementation of copy-on-write for shared_ptr (either from boost or tr1) using unique() is straightforward. Which changes need to be made when multithreading? The reference count is atomic so I assume I can create, copy-construct, read and destroy instances of shared_ptr without further concerns. H...

Error with two ways of linking boost regex

I understand that boost regex static library is created with the ar utility by archiving the individual object files. I linked boost regex library by using the -l option in gcc. This worked very well. g++ *.o libboost_regex-gcc-1_37.a -o sairay.out I individually compiled the boost regex source files and then tried to link the object...

NULL pointer with boost::shared_ptr?

What's the equivalent to the following: std::vector<Foo*> vec; vec.push_back(NULL); when dealing with boost::shared_ptr? Is it the following code? std::vector< boost::shared_ptr<Foo> > vec; vec.push_back(boost::shared_ptr<Foo>()); Note: I may push back a lot of such objects. Should I declare a global static nullPtr object somewhere...

How to intentionally delete a boost::shared_ptr?

I have many boost::shared_ptr<MyClass> objects, and at some point I intentionally want to delete some of them to free some memory. (I know at that point that I will never need the pointed-to MyClass objects anymore.) How can I do that? I guess you can't just call delete() with the raw pointer that I get with get(). I've seen a functio...

boost thread compiler error with GCC

Hello all, on linux, gcc 4.3, compiling a class with boost::thread implementation and mutexes / condition variables I get the following strange error, apparently due to type conflicts with the posix thread library: *Compiling: filter.cpp /usr/include/boost/thread/condition.hpp: In member function »void boost::condition::wait(L&) [with ...

static_cast with boost::shared_ptr?

What is the equivalent of a static_cast with boost::shared_ptr? In other words, how do I have to rewrite the following Base* b = new Base(); Derived* d = static_cast<Derived*>(b); when using shared_ptr? boost::shared_ptr<Base> b(new Base()); boost::shared_ptr<Derived> d = ??? ...

Spurious unblocking in boost thread

I came across this interesting paragraph in the Boost thread documentation today: void wait(boost::unique_lock<boost::mutex>& lock) ... Effects: Atomically call lock.unlock() and blocks the current thread. The thread will unblock when notified by a call to this->notify_one() or this->notify_all(), or spuriously. When the...

TR1 Shared Arrays

I've had a hard time finding references in the TR1 documentation concerning shared arrays. The Boost documentation is fairly clear that there is a significant difference between the C++ "new" and "new[]" expressions. The shared_ptr template is meant to correctly hold a pointer to a dynamically allocated objected created using "new". T...

Is it wise to provide access to weak_ptr in a library interface?

I have written a library that exposes references to several related object types. All of these objects have their lifetimes managed by the library internally via boost::shared_ptr A user of the library would also be able to know, by nature of the library, the lifetimes of any of the exposed objects. So they could store pointers or kee...

returning a 'pointer' which is required to be held by a smart pointer

I have a project which I would like to make more use of smart pointers. Overall, I have been successful in this goal. However, I've come across one things which I'm not sure what the "best practice" is. Basically I would like to return a "pointer" from a function, but require that the user hold it in a smart pointer. Not only that, I do...