boost

Getting Original Regular Expression Out From sregex (Boost Xpressive)

I have the following code. sregex rex = sregex::compile( "(\\w+) (\\w+)!" ); How I can get "(\w+) (\w+)!" out from rex? ...

Ambiguous overload accessing argument-less template functions with variadic parameters

Yeah, the title can scare babies, but it's actually quite straightforward. I am trying to store a function pointer to a specialized template function, namely boost::make_shared (boost 1.41), as illustrated: boost::shared_ptr<int> (*pt2Function)() = boost::make_shared<int>; However, it won't compile (GCC 4.4.1) due to the fact that bo...

Is there a way, using templates, to prevent a class from being derivable in C++

Hi, I need to prevent a class from being derived from so I thought to myself, this is something that Boost is bound to have already done. I know they have a noncopyable, they must have a nonderivable... Imagine my surprise when I couldn't find it.... That got me thinking.. There must be a reason. Maybe it isn't possible to do using te...

Problem with BOOST_CHECK_CLOSE_FRACTION

I'm using the Boost::Test library, and I am trying to check if an actual percent value is close to the expected value: BOOST_CHECK_CLOSE_FRACTION( items[i].ExpectedPercent, items[i].ActualCount / totalCount, 0.05); For some reason this check fails even when the values are close enough: difference between items[i].Expected...

Creating JSON arrays in Boost using Property Trees

I'm trying to create a JSON array using boost property trees. The documentation says: "JSON arrays are mapped to nodes. Each element is a child node with an empty name." So I'd like to create a property tree with empty names, then call write_json(...) to get the array out. However, the documentation doesn't tell me how to create unnam...

Python and Boost - Trying to run vPython and getting __doc__ is read only error.

This is super urgent! Need to get vPython working, can anyone give me help on any way to do this? I'm running on Mac OS X with Python 2.6 , and recently downloaded vPython. Upon installation it also installs the Boost libraries for Python. Now, when I try to import the vPython libraries ('visual'), the following occurs: >>>import v...

boost::intrusive_ptr constructor ambiguity using a class' 'this' pointer

The offending code: template<typename T> class SharedObject { public: typedef boost::intrusive_ptr<T> Pointer; typedef boost::intrusive_ptr<T const> ConstPointer; inline Pointer GetPointer() { return Pointer(this); //Ambiguous call here } inline ConstPointer GetPointer() const { return ConstPointer(this); } ... ...

Is it possible to run only subsets of a Boost unit test module?

I am using the Boost 1.34.1 unit test framework. (I know the version is ancient, but right now updating or switching frameworks is not an option for technical reasons.) I have a single test module (#define BOOST_TEST_MODULE UnitTests) that consists of three test suites (BOOST_AUTO_TEST_SUITE( Suite1 );) which in turn consist of several ...

Modern effective C++ books

Hello Can you give me advice for a modern book(s) for Effective C++ Programming By modern I mean that I want it to include new features from Boost C++ Library (casts, smart pointers, etc.) I have these books: Effective C++: 55 Specific Ways to Improve Your Programs and Designs More Effective C++: 35 New Ways to Improve Your Programs...

Asynchronous write to socket and user values (boost::asio question)

Hello, I'm pretty new to boost. I needed a cross platform low level C++ network API, so I chose asio. Now, I've successfully connected and written to a socket, but since I'm using the asynchronous read/write, I need a way to keep track of the requests (to have some kind of IDs, if you will). I've looked at the documentation/reference, a...

Help understanding boost::bind placeholder arguments

I was reading a StackOverFlow post regarding sorting a vector of pairs by the second element of the pair. The most obvious answer was to create a predicate, but one answer that used boost caught my eye. std::sort(a.begin(), a.end(), boost::bind(&std::pair<int, int>::second, _1) < boost::bind(&std::pair<int, int>::second, _2)); I'...

Looking for a metafunction from bool to bool_type

Basically, I am looking for a library solution that does this: #include <boost/type_traits.hpp> template<bool> struct bool_to_bool_type; template<> struct bool_to_bool_type<false> { typedef boost::false_type type; }; template<> struct bool_to_bool_type<true> { typedef boost::true_type type; }; Is there such a metafunction? ...

Any RAII template in boost or C++0x

Is there any template available in boost for RAII. There are classes like scoped_ptr, shared_ptr which basically work on pointer. Can those classes be used for any other resources other than pointers. Is there any template which works with a general resources. Take for example some resource which is acquired in the beginning of a scope ...

Why does using boost increase file size so much?

I've noticed that when I use a boost feature the app size tends to increase by about .1 - .3 MB. This may not seem like much, but compared to using other external libraries it is (for me at least). Why is this? ...

C++ container/array/tuple consistent access interface

hello Is there, perhaps in boost, consistent element access semantics which works across containers? something along the lines of: element_of(std_pair).get<1>(); element_of(boost_tuple).get<0>(); element_of(pod_array).get<2>(); in principle i can write myself, but I would rather not reinvent the wheel.thanks ...

How to determine if a file can be written using C++

In C++ how can I determine if the program has either read-only access or read-write access to a file? I searched the boost filesystem library but I have yet to find something to help me. Right now I thinking of opening the file, trying to write inside and check for error, but that doesn't seem a very appropriate way of doing this. Any c...

How to pass a row of boost::multi_array and std::vector by reference to the same template function?

I have a problem with this bit of code: #include <boost/multi_array.hpp> #include <boost/array.hpp> #include <vector> #include <iostream> template <typename Vec> void foo(Vec& x, size_t N) { for (size_t i = 0; i < N; ++i) { x[i] = i; } } int main() { std::vector<double> v1(10); foo(v1, 5); std::cout << v1[4...

Specific Time Zone In boost::posix_time::ptime

I have the following time : 2010-01-25 03:13:34.384 - GMT Time Zone 2010-01-25 11:13:34.384 - My Local I wish to convert to timestamp in ms. However, since I only obtain local time string from caller "2010-01-25 11:13:34.384" If I do it this way : // ts is "2010-01-25 11:13:34.384" (My Local) boost::posix_time::ptime t(boost::posix_...

storing line numbers of expressions with boost.spirit 2

I am planning on doing a script transformation utility (for extended diagnostic information) using Boost.Spirit 2. While there is support for line information etc. for parsing errors, how i can store line numbers for successfully parsed expressions with Qi? ...

Boost Logging in 64 bit mode

Hi,I am using boost library for logging purpose. It is working fine with x86 bit mode but is not functioning in x64 bit mode.Kindly let me know the possible solution/steps to debug and fix this issue. Thanks in advance. Regards, Sumanta ...