boost

Can boost filesystem change the read-only attribute of a file?

Is there a way to change the attribute of a file from read-only to read-write using the boost filesystem library? If not, what is the next-best way to do this on Windows (using Microsoft's C++)? ...

Compose output streams

I'd like to compose two (or more) streams into one. My goal is that any output directed to cout, cerr, and clog also be outputted into a file, along with the original stream. (For when things are logged to the console, for example. After closing, I'd like to still be able to go back and view the output.) I was thinking of doing somethin...

Weighted random numbers

I'm trying to implement a weighted random numbers. I'm currently just banging my head against the wall and cannot figure this out. In my project (Hold'em hand-ranges, subjective all-in equity analysis), I'm using Boost's random -functions. So, let's say I want to pick a random number between 1 and 3 (so either 1, 2 or 3). Boost's mersen...

boost filtering_istream gzip_decompressor uncompressed file size

I am using the boost filtering stream object to read gzipped files. Works great! I would like to display a progress bar for the amount of the file that has been processed. I need find the input uncompressed file size. Does the gzip decompressor have access to the original file size from the gzipped file? I couldn't find it on the boo...

Using Cygwin to build srecord for native Windows

I'm trying to build the srecord tools for the native windows, http://srecord.sourceforge.net/windows.html. I execute, CC='gcc -mno-cygwin' CXX='g++ -mno-cygwin' ./configure. I get a failure as it is checking for boost libraries, see error text below. I installed the current verison of cygwin (as of 18-Nov-2009) including both the gcc and...

Boost cheat sheet

I just had a hell of a project doing simple operations on C++, then when I was almost completely done with the project I found out that all this stupid tasks required just a portion of boost. This was quite frustrating and let me wondering how many of these annoying problems could be solved with a single function of the boost libraries. ...

Determine Parent Class from boost::any

May I know is there any way to determine parent class from boost::any? #include <iostream> #include <boost/any.hpp> class a { public: virtual ~a() {} }; class b : public a { }; bool is_class_a(const boost::any& any) { return boost::any_cast<a>(&any) != 0; } bool is_class_a_v2(const boost::any& any) { try { bo...

Building Boost on Linux - library names

I am trying to build an application which depends on Boost. So I downloaded Boost 1_41_0 to my Linux box and followed the instructions found on the Boost site for Unix variants, http://www.boost.org/doc/libs/1%5F41%5F0/more/getting%5Fstarted/unix-variants.html. They basically suggest that I run ./bjam install, which I did. The build c...

Cross platform unicode path handling

I'm using boost::filesystem for cross-platform path manipulation, but this breaks down when calls need to be made down into interfaces I don't control that won't accept UTF-8. For example when using the Windows API, I need to convert to UTF-16, and then call the wide-string version of whatever function I was about to call, and then conve...

shared_ptr vs scoped_ptr

scoped_ptr is not copy able and is being deleted out of the scope. So it is kind of restricted shared_ptr. So seems besides the cases when you really need to restrict the copy operation shared_ptr is better to use. Because sometimes you don’t know you need to create a copy of your object or no. So the question is: besides the cases menti...

boost to_upper function of string_algo doesn't take into account the locale

I have a problem with the functions in the string_algo package. Consider this piece of code: #include <boost/algorithm/string.hpp> int main() { try{ string s = "meißen"; locale l("de_DE.UTF-8"); to_upper(s, l); cout << s << endl; catch(std::runtime_error& e){ cerr << e.what() << endl; } try{ ...

help needed with boost python...

Hai friends, I've installed boost python from ubuntu 9.04 repositories.. I've successfully run the Build a Simple Program Using Boost from the tutorial http://www.boost.org/doc/libs/1%5F41%5F0...-variants.html . So i ensured that boost python is installed in my system.. But for the program below #include <string> namespace { // Avoid ...

boost split compile issue

I have the following code snippet. I am compiling using the sun studio 12 compiler and have tried boost 1.33 and 1.39 #include <boost/algorithm/string.hpp> #include <string> #include <vector> using namespace boost; using namespace std; int main(int argc, char* argv[]) { string exbyte = "0x2430"; string exbytes = "0x2430,2430...

boost linker errors -regular expressions - c++

hi am trying to compile a simple program in boost library but i keep getting linker errors #include <iostream> #include <string> #include <boost\regex.hpp> // Boost.Regex lib using namespace std; int main( ) { std::string s, sre; boost::regex re; while(true) { cout << "Expression: "; cin >> sre; if (...

Base Class Pointer to Hold Boost Enum

Currently, I am using a type-safe enum class from Boost Vault : http://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using I found it is difficult to have a parent class pointer to refer to all enum class, due to Boost::enum is a template class : boost::detail::enum_base<T> I am using void fun(const boost::any& a...

Boost::asio async_wait handler signature

Hi, I am going through the boost::asio examples. I am looking at Example 4 What is confusing is that, the WaitHandler in this example has the signature void print (this) But the async_wait call expects a handler whose function signature of the handler must be: void handler( const boost::system::error_code& error ...

Import Error on boost python hello program

Hello World Code #include <boost/python.hpp> using namespace boost::python; struct World{ void set(std::string msg) { this->msg = msg; } std::string greet() { return msg; } std::string msg; }; BOOST_PYTHON_MODULE(hello) { class_<World>("World") .def("greet", &World::greet) .def("set", &World::set) ;...

Boost::Random and Enumerated Types

Right now I'm generating a random enumerator using boost's random library. Basically I'm using an implicit conversion to specify the random generator's distribution, getting a random number, and then casting that back to the enumerated type. Ex: (minColor and maxColor are parameters of the enumerated type) boost::mt19937 randGen(std::t...

Boost Serialization Compile Errors, terribly confused

Okay so basically : i have this simple example: main.cpp using namespace VHGO::Resource; std::list<BaseTable*> tableList; BigTable* bt1 = new BigTable(); HRESULT hr = S_OK; hr = bt1->Add(L"TEXTURE", L"..\\Data\\ground.png"); tableList.push_back(bt1); std::wofstream ofs3(L"VHGOSatData.bif"); boost::archive::xml_woarchive outArch3(of...

Using Boost on Windows (Visual Studio)

I want to get started using Boost. I'm programming a C++ program in Visual Studio (obviously on a Windows machine). Boost's Getting Started Guide says: The easiest way to get a copy of Boost is to use an installer. The Boost website version of this Getting Started guide will have undated information on installers as they become avai...