Search Results

Search found 1726 results on 70 pages for 'boost'.

Page 15/70 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • How should I compile boost library in a small project?

    - by Vincenzo
    I have a small project where I need just part of boost library, boost::regex in particular. This is what I've done so far: /include /boost /regex /math .. 189 dirs, files, etc. /lib /boost-regex c_regex_traits.cpp cpp_regex_traits.cpp .. ~20 .cpp files myprog.cpp In my Makefile I compile all boost-regex .cpp files one by one, producing .obj files. Next, I'm building my project by means of compiling myprog.cpp together with all that .obj files from /lib/boost/regex. The question is whether I'm doing everything correct? The size of my output file is rather big (~3.5Mb), while my code is extremely small (10 lines).

    Read the article

  • Boost MultiIndex - objects or pointers (and how to use them?)?

    - by Sarah
    I'm programming an agent-based simulation and have decided that Boost's MultiIndex is probably the most efficient container for my agents. I'm not a professional programmer, and my background is very spotty. I've two questions: Is it better to have the container contain the agents (of class Host) themselves, or is it more efficient for the container to hold Host *? Hosts will sometimes be deleted from memory (that's my plan, anyway... need to read up on new and delete). Hosts' private variables will get updated occasionally, which I hope to do through the modify function in MultiIndex. There will be no other copies of Hosts in the simulation, i.e., they will not be used in any other containers. If I use pointers to Hosts, how do I set up the key extraction properly? My code below doesn't compile. // main.cpp - ATTEMPTED POINTER VERSION ... #include <boost/multi_index_container.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/tokenizer.hpp> typedef multi_index_container< Host *, indexed_by< // hash by Host::id hashed_unique< BOOST_MULTI_INDEX_MEM_FUN(Host,int,Host::getID) > // arg errors here > // end indexed_by > HostContainer; ... int main() { ... HostContainer testHosts; Host * newHostPtr; newHostPtr = new Host( t, DOB, idCtr, 0, currentEvents ); testHosts.insert( newHostPtr ); ... } I can't find a precisely analogous example in the Boost documentation, and my knowledge of C++ syntax is still very weak. The code does appear to work when I replace all the pointer references with the class objects themselves. As best I can read it, the Boost documentation (see summary table at bottom) implies I should be able to use member functions with pointer elements.

    Read the article

  • Convert C++Builder AnsiString to std::string via boost::lexical_cast

    - by David Klein
    For a school assignment I have to implement a project in C++ using Borland C++ Builder. As the VCL uses AnsiString for all GUI Components I have to convert all of my std::strings to AnsiString for the sake of displaying. std::string inp = "Hello world!"; AnsiString outp(inp.c_str()); works of course but is a bit tedious to write and code duplication I want to avoid. As we use Boost in other contexts I decided to provide some helper functions go get boost::lexical_cast to work with AnsiString. Here is my implementation so far: std::istream& operator>>(std::istream& istr, AnsiString& str) { istr.exceptions(std::ios::badbit | std::ios::failbit | std::ios::eofbit); std::string s; std::getline(istr,s); str = AnsiString(s.c_str()); return istr; } In the beginning I got Access Violation after Access Violation but since I added the .exceptions() stuff the picture gets clearer. When the conversion is performed I get the following Exception: ios_base::eofbit set [Runtime Error/std::ios_base::failure] Does anyone have an idea how to fix it and can explain why the error occurs? My C++ experience is very limited. The conversion routine the other way round would be: std::ostream& operator<<(std::ostream& ostr,const AnsiString& str) { ostr << (str.c_str()); return ostr; } Maybe someone will spot an error here too :) With best regards! Edit: At the moment I'm using the edited version of Jem, it works in the beginning. After a while of using the programm the Borland Codeguard mentions some pointer arithmetic in already freed regions. Any ideas how this could be related? The Codeguard log (I'm using the german version, translations marked with stars): ------------------------------------------ Fehler 00080. 0x104230 (r) (Thread 0x07A4): Zeigerarithmetik in freigegebenem Speicher: 0x0241A238-0x0241A258. **(pointer arithmetic in freed region)** | d:\program files\borland\bds\4.0\include\dinkumware\sstream Zeile 126: | { // not first growth, adjust pointers | _Seekhigh = _Seekhigh - _Mysb::eback() + _Ptr; |> _Mysb::setp(_Mysb::pbase() - _Mysb::eback() + _Ptr, | _Mysb::pptr() - _Mysb::eback() + _Ptr, _Ptr + _Newsize); | if (_Mystate & _Noread) Aufrufhierarchie: **(stack-trace)** 0x00411731(=FOSChampion.exe:0x01:010731) d:\program files\borland\bds\4.0\include\dinkumware\sstream#126 0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465 0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151 0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679 0x00405759(=FOSChampion.exe:0x01:004759) D:\Projekte\Schule\foschamp\src\Server\Ansistringkonverter.h#31 0x004080C9(=FOSChampion.exe:0x01:0070C9) D:\Projekte\Schule\foschamp\lib\boost_1_34_1\boost/lexical_cast.hpp#151 Objekt (0x0241A238) [Größe: 32 Byte] war erstellt mit new **(Object was created with new)** | d:\program files\borland\bds\4.0\include\dinkumware\xmemory Zeile 28: | _Ty _FARQ *_Allocate(_SIZT _Count, _Ty _FARQ *) | { // allocate storage for _Count elements of type _Ty |> return ((_Ty _FARQ *)::operator new(_Count * sizeof (_Ty))); | } | Aufrufhierarchie: **(stack-trace)** 0x0040ED90(=FOSChampion.exe:0x01:00DD90) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#28 0x0040E194(=FOSChampion.exe:0x01:00D194) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#143 0x004115CF(=FOSChampion.exe:0x01:0105CF) d:\program files\borland\bds\4.0\include\dinkumware\sstream#105 0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465 0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151 0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679 Objekt (0x0241A238) war Gelöscht mit delete **(Object was deleted with delete)** | d:\program files\borland\bds\4.0\include\dinkumware\xmemory Zeile 138: | void deallocate(pointer _Ptr, size_type) | { // deallocate object at _Ptr, ignore size |> ::operator delete(_Ptr); | } | Aufrufhierarchie: **(stack-trace)** 0x004044C6(=FOSChampion.exe:0x01:0034C6) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#138 0x00411628(=FOSChampion.exe:0x01:010628) d:\program files\borland\bds\4.0\include\dinkumware\sstream#111 0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465 0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151 0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679 0x00405759(=FOSChampion.exe:0x01:004759) D:\Projekte\Schule\foschamp\src\Server\Ansistringkonverter.h#31 ------------------------------------------ Ansistringkonverter.h is the file with the posted operators and line 31 is: std::ostream& operator<<(std::ostream& ostr,const AnsiString& str) { ostr << (str.c_str()); **(31)** return ostr; } Thanks for your help :)

    Read the article

  • [C++] Producer/Consumer Implementation -- Feedback Wanted

    - by bobber205
    I'm preparing for an interview in a few weeks and I thougth I would give threads in boost a go, as well as do the simple producer/consumer problem I learned in school. Haven't done it quite awhile so I was curious what you guys think of this? What should I add to make it a better example etc. Thanks for the feedback! :) ////////////////////////////////////////////////////////////////////////// boost::mutex bufferMutex; deque<int> buffer; const int maxBufferSize = 5; ////////////////////////////////////////////////////////////////////////// bool AddToBuffer(int i) { if (buffer.size() < maxBufferSize) { buffer.push_back(i); return true; } else { return false; } } bool GetFromBuffer(int& toReturn) { if (buffer.size() == 0) { return false; } else { toReturn = buffer[buffer.size()-1]; buffer.pop_back(); return true; } } struct Producer { int ID; void operator()() { while (true) { boost::mutex::scoped_lock lock(bufferMutex); int num = dice(); bool result = AddToBuffer(num); lock.unlock(); //safe area done if (result) { cout << "Producer " << this->ID << " Added " << num << endl; } else { cout << "!!Buffer was Full!!" << endl; } //Added //Now wait boost::xtime xt; xtime_get( &xt, boost::TIME_UTC); xt.nsec += 1000000 + 100000 * (rand() % 1000); boost::thread::sleep(xt); } } }; struct Consumer { int ID; void operator()() { while (true) { int returnedInt = 0; boost::mutex::scoped_lock lock(bufferMutex); bool result = GetFromBuffer(returnedInt); lock.unlock(); //safe area done if (result) { cout << "\tConsumer " << this->ID << " Took Out " << returnedInt << endl; } else { cout << "!!Buffer was Empty!!" << endl; } //Added //Now wait boost::xtime xt; xtime_get( &xt, boost::TIME_UTC); xt.nsec += 1000000 + 100000 * (rand() % 1000); boost::thread::sleep(xt); } } }; void main() { Producer p, p2; Consumer c, c2; p.ID = 1; p2.ID = 2; c.ID = 1; c2.ID = 2; boost::thread thread1(boost::ref(p)); boost::thread thread2(boost::ref(c)); boost::thread thread3(boost::ref(p2)); boost::thread thread4(boost::ref(c2)); int x; cin >> x; }

    Read the article

  • Display Graph using Boost Graph Library

    - by TheTSPSolver
    Can anyone please tell me that once I've created a graph using Boost Graph library, how can I display that graph? My biggest concern is that the edge weights are coming from an exernal data source over the network. And I need to be able to display the edgeweights live as they get updated.

    Read the article

  • Can someone provide an example of seeking, reading, and writing a >4GB file using boost iostreams

    - by Queueless
    I have read that boost iostreams supposedly supports 64 bit access to large files semi-portable way. Their FAQ mentions 64 bit offset functions, but there is no examples on how to use them. Has anyone used this library for handling large files? A simple example of opening two files, seeking to their middles, and copying one to the other would be very helpful. Thanks.

    Read the article

  • How do I make Boost multithreading?

    - by john
    Hi, I am trying to compile the latest Boost c++ libraries for Centos. I 've used bjam install and it has placed the libraries in /usr/lib and /usr/lib64. The problem is I need the -mt variants for a specific application to run. I cannot understand in the documentation how to create the multithreading variants. :( Please give me a hint! Thanks!

    Read the article

  • boost smart pointers and BOOST_NO_MEMBER_TEMPLATES

    - by Johann Gerell
    After some struggling I managed to get boost smart pointers to build for Windows CE/Mobile at warning level 4. I found the least-resistance-way to get rid of compile errors and warnings to be #define BOOST_NO_MEMBER_TEMPLATES What does it actually mean? Did I sell my soul to the devil? Will all hell break loose when I actually use the types?

    Read the article

  • Modifying vertex properties in a Boost::Graph

    - by Paul Nathan
    I am trying to figure out how to use boost::graph to store some information. However, there is information I want tied to each vertex. Staring at the documentation for the library reveals either(a)badly written documentation, or (b), I'm obviously not as good at C++ as I thought. Pick two. I am looking for either a tutorial on assigning properties, or a simple example use.

    Read the article

  • Compatibility between Qt and Boost sockets libraries

    - by cake
    Hello In my work, I'm developing a Viewer client for a Offshore simulation server, using sockets to send the simulation data from the Simulator to de Viewer. But, the server uses Boost.asio as it's sockets library. As the client uses Qt for it's GUI, I was wondering if there is any problem in using de Qt Networking library for handling the sockets. Is there any compatibility issues? Thanks in advance, and sorry for my bad english.

    Read the article

  • XCode with boost "Sematic Issue - undeclared identifier va_start"

    - by Paulo Henrique
    C++locale.h ->Semantic Issue -->Use of undeclared identifier 'va_start' ->Semantic Issue -->Use of undeclared identifier 'va_end' First time using boost, downloaded it using ports and created a command line project in XCode. Header Search Path: /usr/include/** There is nothing in the code yet, just the main function that comes with the default proj. Just don't know what to do, never expected this to happen.

    Read the article

  • Boost BGL thread safety

    - by Budzoli
    Hi! I'd like multiple threads to use the dijkstra_shortest_paths and astar_search functions of the BGL, and then read the property maps of the result vertices and edges. I'm wondering wether I should use mutexes to ensure thread-safety. So here are my questions: 1., Are the dijkstra_shortest_paths and astar_search functions of the Boost.Graph thread safe? 2., If I only try to read the property maps of the graph from multiple threads, do I need to worry about thread safety?

    Read the article

  • How to tell what optimizations bjam is using to build boost

    - by Steve
    I'm building the boost libraries with bjam for both the intel compiler and vs2008, and I can't tell what optimizations are being passed to the compiler from bjam. For one of the compiler's gcc, I can see some optimizations in one of the bjam files, but I can't find the optimization flags for the compilers I care about. So, my questions are - Does anyone know where the default optimization flags are located? If they're declared within bjam, does anyone know how I can override them?

    Read the article

  • Boost.Test: Looking for a working non-Trivial Test Suite Example / Tutorial

    - by Robert S. Barnes
    The Boost.Test documentation and examples don't really seem to contain any non-trivial examples and so far the two tutorials I've found here and here while helpful are both fairly basic. I would like to have a master test suite for the entire project, while maintaining per module suites of unit tests and fixtures that can be run independently. I'll also be using a mock server to test various networking edge cases. I'm on Ubuntu 8.04, but I'll take any example Linux or Windows since I'm writing my own makefiles anyways.

    Read the article

  • Pretty printing boost::unordered_map on gdb

    - by scooterman
    Hi all, recently I've started to use the excellent boost::unordered_map on my system, but got one drawback: I couldn't figure how to inspect its contents. Printing it on gdb gives me a table_ and a buckets_, but haven't found where are the items. Anyone has a clue about this?

    Read the article

  • Why isn't the boost::shared_ptr -> operator inlined?

    - by Alan
    Since boost::shared_ptr could be called very frequently and simply returns a pointer, isn't the -> operator a good candidate for being inlined? T * operator-> () const // never throws { BOOST_ASSERT(px != 0); return px; } Would a good compiler automatically inline this anyway? Should I lose any sleep over this? :-)

    Read the article

  • Boost multi_index ordered_unique Median Value

    - by Autopulated
    I would like to quickly retrieve the median value from a boost multi_index container with an ordered_unique index, however the index iterators aren't random access (I don't understand why they can't be, though this is consistent with std::set...). Is there a faster/neater way to do this other than incrementing an iterator container.size() / 2 times?

    Read the article

  • C++ boost thread reusing threads

    - by aaa
    hi. I am trying to accomplish something like this: thread t; // create/initialize thread t.launch(); // launch thread. t.wait(); // wait t.launch(); // relaunch the same thread How to go about implementing something like this using boost threads? in essence, I need persistent relaunch-able thread. Thanks

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >