Search Results

Search found 645 results on 26 pages for 'stl'.

Page 3/26 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Easier debugging stl array

    - by bobobobo
    In MSVC++ I have a vector. Whenever you go out of bounds of the vector (in debug mode, launched as "Start Debugging"), when you step out of bounds of the vector the program halts with a dialog box: Microsoft Visual C++ Debug Library ==== Debug Assertion Failed! Expression: Vector subscript out of range Abort | Retry | Ignore So what I want though is the MSVC++ debugger within visual studio to STOP AT THE LINE WHERE THE OUT OF BOUNDS OCCURRED, not give me this dialog box. How can I cause the program to "break" properly and be able to step through code /inspect variables when an out of bounds occurs on an STL vector?

    Read the article

  • STL map inside map C++

    - by Prasanth Madhavan
    In c++ STL map, i have a definition like map<string, map<int, string> >; and i iterate it using the following code. for( map<string, map<int, string> >::iterator ii=info.begin(); ii!=info.end(); ++ii){ for(map<int, string>::iterator j=ii->second.begin(); j!=ii->second.end();++j){ cout << (*ii).first << " : " << (*j).first << " : "<< (*j).second << endl; } } My doubt is is this the correct way to iterate or is there a better way to do so? The above code works for me. But m looking for a more elegant solution.

    Read the article

  • STL map--> sort by value?

    - by Charlie Epps
    Hi I wonder how can I implement the STL map sorting by value. For example, I have a map m map<int, int>; m[1] = 10; m[2] = 5; m[4] = 6; m[6] = 1; and then.. I'd like to sort that with the m's value. So, if I print the map, I'd like to get the result like m[6] = 1 m[2] = 5 m[4] = 6 m[1] = 10 this. How can I sort like this way? Is there any way that I can deal with the key and value with sorted values?

    Read the article

  • Using objects with STL vector - minimal set of methods

    - by osgx
    Hello What is "minimal framework" (necessary methods) of object, which I will use with STL <vector>? For my assumptions: #include <vector> #include <cstring> using namespace std; class Doit { private: char *a; public: Doit(){a=(char*)malloc(10);} ~Doit(){free(a);} }; int main(){ vector<Doit> v(10); } gives *** glibc detected *** ./a.out: double free or corruption (fasttop): 0x0804b008 *** Aborted and in valgrind: malloc/free: 2 allocs, 12 frees, 50 bytes allocated.

    Read the article

  • Hidden Features and Dark Corners of STL?

    - by Andrei
    C++ developers, all know the basics of C++: Declarations, conditionals, loops, operators, etc. Some of us even mastered the stuff like templates, object model, complex I/O, etc. But what are the most hidden features or tricks or dark corners of C++/STL that even C++ fans, addicts, and experts barely know? I am talking about a seasoned C++ programmer (be she/he a developer, student, fan, all three, etc), who thinks (s)he knows something 99% of us never heard or dreamed about. Something that not only makes his/her work easier, but also cool and hackish. After all, C++ is one of the most used programming languages in the world, thus it should have intricacies that only a few privileged know about and want to share with us. Boost is welcome too! One per post with an example please P.S Examples are important for other developers to copy and paste!

    Read the article

  • Switching from C++ (with a lot of STL use) to C for interpreter building

    - by wndsr
    I'm switching from C++ to C because I'm rebuilding my toy interpreter. I was used to vectors for dynamic allocation of objects like tokens or instructions of my programs, stacks and mainly strings with all their aspects. Now, in C I'm not going to have all these anymore. I know that I will have to use a lot of memory management, too. I'm completely new to C, I only know the high-level easy-life data structures from the STL, how can I get started with strings and dynamic memory allocation?

    Read the article

  • How to change size of STL container in C++

    - by Jaime Pardos
    I have a piece of performance critical code written with pointers and dynamic memory. I would like to rewrite it with STL containers, but I'm a bit concerned with performance. Is there a way to increase the size of a container without initializing the data? For example, instead of doing ptr = new BYTE[x]; I want to do something like vec.insert(vec.begin(), x, 0); However this initializes every byte to 0. Isn't there a way to just make the vector grow? I know about reserve() but it just allocates memory, it doesn't change the size of the vector, and doesn't allows me to access it until I have inserted valid data. Thank you everyone.

    Read the article

  • STL deque accessing by index is O(1)?

    - by jasonline
    I've read that accessing elements by position index can be done in constant time in a STL deque. As far as I know, elements in a deque may be stored in several non-contiguous locations, eliminating safe access through pointer arithmetic. For example: abc-defghi-jkl-mnop The elements of the deque above consists of a single character. The set of characters in one group indicate it is allocated in contiguous memory (e.g. abc is in a single block of memory, defhi is located in another block of memory, etc.). Can anyone explain how accessing by position index can be done in constant time, especially if the element to be accessed is in the second block? Or does a deque have a pointer to the group of blocks? Update: Or is there any other common implementation for a deque?

    Read the article

  • How is the syntax for stl iterators implemented?

    - by Liberalkid
    I've been working on writing a library in my spare time to familiarize myself more with c++ and singular value decomposition. I've been working on writing an Iterator class and I'm entirely capable of writing the functionality and I have already for my own currently MatrixIterator class. I'm guessing that it involves namespaces because: vector<int>::iterator Would appear to be an iterator from the namespace vector, but namespaces are another topic which I'm not familiar with. Mainly I'm asking what would it involve to implement an iterator such that it could be referenced in a similar way to the stl iterators. I'm also aware that I could use boost.iterators or something similar to save myself a lot of work, but I'm more interested in learning all of the details that go into something like this.

    Read the article

  • Storing objects in STL vector - minimal set of methods

    - by osgx
    Hello What is "minimal framework" (necessary methods) of object, which I will store in STL <vector>? For my assumptions: #include <vector> #include <cstring> using namespace std; class Doit { private: char *a; public: Doit(){a=(char*)malloc(10);} ~Doit(){free(a);} }; int main(){ vector<Doit> v(10); } gives *** glibc detected *** ./a.out: double free or corruption (fasttop): 0x0804b008 *** Aborted and in valgrind: malloc/free: 2 allocs, 12 frees, 50 bytes allocated.

    Read the article

  • Obtain container type from (its) iterator type in C++ (STL)

    - by KRao
    It is easy given a container to get the associated iterators, example: std::vector<double>::iterator i; //An iterator to a std::vector<double> I was wondering if it is possible, given an iterator type, to deduce the type of the "corresponding container" (here I am assuming that for each container there is one and only one (non-const) iterator). More precisely, I would like a template metafunction that works with all STL containers (without having to specialize it manually for each single container) such that, for example: ContainerOf< std::vector<double>::iterator >::type evaluates to std::vector<double> Is it possible? If not, why? Thank you in advance for any help!

    Read the article

  • STL for games, yea or nay?

    - by munificent
    Every programming language has its standard library of containers, algorithms, and other helpful stuff. With languages like C#, Java, and Python, it's practically inconceivable to use the language without its standard lib. Yet, on many C++ games I've worked on, we either didn't use the STL at all, used a tiny fraction of it, or used our own implementation. It's hard to tell if that was a sound decision for our games, or one simply made out of ignorance of the STL. So... is the STL a good fit or not?

    Read the article

  • STL for games, yea or nay?

    - by munificent
    Every programming language has its standard library of containers, algorithms, and other helpful stuff. With languages like C#, Java, and Python, it's practically inconceivable to use the language without its standard lib. Yet, on many C++ games I've worked on, we either didn't use the STL at all, used a tiny fraction of it, or used our own implementation. It's hard to tell if that was a sound decision for our games, or one simply made out of ignorance of the STL. So... is the STL a good fit or not?

    Read the article

  • VS2008 -> VS2010 leads to cryptic STL errors

    - by Jakobud
    The following C++ library was successfully compiled in VS2008 http://sourceforge.net/projects/xmlrpcc4win/files/xmlrpcc4win/XmlRpcC4Win1.0.8.zip/download When I open it in VS2010, it goes through the conversion wizard process without any errors. Now, when I attempt to compile it in VS2010, I get some weird STL errors like these: 1>TimXmlRpc.cpp(1018): error C2039: 'back_insert_iterator' : is not a member of 'std' 1>TimXmlRpc.cpp(1018): error C2065: 'back_insert_iterator' : undeclared identifier 1>TimXmlRpc.cpp(1018): error C2275: 'XmlRpcValue::BinaryData' : illegal use of this type as an expression 1>TimXmlRpc.cpp(1018): error C2065: 'ins' : undeclared identifier 1>TimXmlRpc.cpp(1018): error C2039: 'back_inserter' : is not a member of 'std' 1>TimXmlRpc.cpp(1018): error C3861: 'back_inserter': identifier not found 1>TimXmlRpc.cpp(1019): error C2065: 'ins' : undeclared identifier 1>TimXmlRpc.cpp(1031): error C2039: 'back_insert_iterator' : is not a member of 'std' 1>TimXmlRpc.cpp(1031): error C2065: 'back_insert_iterator' : undeclared identifier 1>TimXmlRpc.cpp(1031): error C2275: 'std::vector<_Ty>' : illegal use of this type as an expression 1> with 1> [ 1> _Ty=char 1> ] 1>TimXmlRpc.cpp(1031): error C2065: 'ins' : undeclared identifier 1>TimXmlRpc.cpp(1031): error C2039: 'back_inserter' : is not a member of 'std' 1>TimXmlRpc.cpp(1031): error C3861: 'back_inserter': identifier not found 1>TimXmlRpc.cpp(1032): error C2065: 'ins' : undeclared identifier I'm not sure what to make of some of these. For instance, back_insert_iterator is in fact a member of std, but VS doesn't seem to think it is. How do I fix errors like these? They just don't seem to make much sense so I'm not sure where to begin. Perhaps its something in my project settings? For example, here is line 1018, which gives the std error: std::back_insert_iterator<BinaryData> ins = std::back_inserter(*(u.asBinary)); If anyone could give me some direction I'd appreciate it. I'm new enough to C++ that I'm having a tough time figuring out this one.

    Read the article

  • maps, iterators, and complex structs - STL errors

    - by Austin Hyde
    So, I have two structs: struct coordinate { float x; float y; } struct person { int id; coordinate location; } and a function operating on coordinates: float distance(const coordinate& c1, const coordinate& c2); In my main method, I have the following code: map<int,person> people; // populate people map<int,map<float,int> > distance_map; map<int,person>::iterator it1,it2; for (it1=people.begin(); it1!=people.end(); ++it1) { for (it2=people.begin(); it2!=people.end(); ++it2) { float d = distance(it1->second.location,it2->second.location); distance_map[it1->first][d] = it2->first; } } However, I get the following error upon build: stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits<coordinate>’: stl_iterator_base_types.h:129: error: no type named ‘iterator_category’ in ‘struct coordinate’ stl_iterator_base_types.h:130: error: no type named ‘value_type’ in ‘struct coordinate’ stl_iterator_base_types.h:131: error: no type named ‘difference_type’ in ‘struct coordinate’ stl_iterator_base_types.h:132: error: no type named ‘pointer’ in ‘struct coordinate’ stl_iterator_base_types.h:133: error: no type named ‘reference’ in ‘struct coordinate’ And it blames it on the line: float d = distance(it1->second.location,it2->second.location); Why does the STL complain about my code?

    Read the article

  • shared memory STL maps

    - by user306963
    Hello, I am writing an Apache module in C++. I need to store the common data that all childs need to read as a portion of shared memory. Structure is kind of map of vectors, so I want to use STL map and vectors for it. I have written a shared allocator and a shared manager for the purpose, they work fine for vectors but not for maps, below is the example: typedef vector<CustomersData, SharedAllocator<CustomersData> > CustomerVector; CustomerVector spData; //this one works fine typedef SharedAllocator< pair< const int, CustomerVector > > PairAllocator; typedef map< int, CustomerVector, less<int>, PairAllocator > SharedMap; SharedMap spIndex; //this one doesn't work I get compile time errors when I try to use the second object (spIndex), which are someting like: ../SpatialIndex.h:97: error: '((SpatialIndex*)this)-SpatialIndex::spIndex' does not have class type It looks like the compiler cannot determine a type for SharedMap template type, which is strange in my opinion, it seems to me that all the template parameters have been specified. Can you help? Thanks Benvenuto

    Read the article

  • Idiomatic STL: Iterating over a list and inserting elements

    - by mkilling
    I'm writing an algorithm that iterates over a list of points, calculates the distance between them and inserts additional points if the distance is too great. However I seem to be lacking the proper familiarity with STL to come up with an elegant solution. I'm hoping that I can learn something, so I'll just show you my code. You might have some hints for me. for (std::list<PathPoint>::iterator it = ++points_.begin(); it != points_.end(); it++) { Vector curPos = it->getPosition(); Vector prevPos = (--it)->getPosition(); Vector vecFromPrev = curPos - prevPos; float distance = vecFromPrev.abs(); it++; if (distance > MAX_DISTANCE_BETWEEN_POINTS) { int pointsToInsert = (int)(distance / MAX_DISTANCE_BETWEEN_POINTS); Vector curPos = prevPos; for (int i = 0; i < pointsToInsert; i++) { curPos += vecFromPrev / pointsToInsert; it = points_.insert(it, PathPoint(curPos, false)); it++; } } }

    Read the article

  • How to load/save C++ class instance (using STL containers) to disk

    - by supert
    I have a C++ class representing a hierarchically organised data tree which is very large (~Gb, basically as large as I can get away with in memory). It uses an STL list to store information at each node plus iterators to other nodes. Each node has only one parent, but 0-10 children. Abstracted, it looks something like: struct node { public: node_list_iterator parent; // iterator to a single parent node double node_data_array[X]; map<int,node_list_iterator> children; // iterators to child nodes }; class strategy { private: list<node> tree; // hierarchically linked list of nodes struct some_other_data; public: void build(); // build the tree void save(); // save the tree from disk void load(); // load the tree from disk void use(); // use the tree }; I would like to implement the load() and save() to disk, and it should be fairly fast, however the obvious problems are: I don't know the size in advance; The data contains iterators, which are volatile; My ignorance of C++ is prodigious. Could anyone suggest a pure C++ solution please?

    Read the article

  • C++ STL question related to insert iterators and sets

    - by rshepherd
    #include #include #include #include using namespace std; class MyContainer { public: string value; MyContainer& operator=(const string& s) { this->value = s; return *this; } }; int main() { list<string> strings; strings.push_back("0"); strings.push_back("1"); strings.push_back("2"); set<MyContainer> containers; copy(strings.begin(), strings.end(), inserter(containers, containers.end())); } The preceeding code does not compile. In typical STL style the error output is verbose and difficult to understand. The key part seems to be this... /usr/include/c++/4.4/bits/stl_algobase.h:313: error: no match for ‘operator=’ in ‘__result.std::insert_iterator::operator* [with _Container = std::set, std::allocator ]() = __first.std::_List_iterator::operator* [with _Tp = std::basic_string, std::allocator ]()’ ...which I interpet to mean that the assignment operator needed is not defined. I took a look at the source code for insert_iterator and noted that it has overloaded the assignment operator. The copy algorithm must uses the insert iterators overloaded assignment operator to do its work(?). I guess that because my input iterator is on a container of strings and my output iterator is on a container of MyContainers that the overloaded insert_iterator assignment operator can no longer work. This is my best guess, but I am probably wrong. So, why exactly does this not work and how can I accomplish what I am trying to do?

    Read the article

  • C++ STL make_heap and pop_heap not working.

    - by Henrique
    I need to use a Heap, so i've searched about the STL one, but it doesn't seem to work, i wrote some code to explain what i mean: #include <stdio.h> #include <stdlib.h> #include <vector> #include <algorithm> struct data { int indice; int tamanho; }; bool comparator2(const data* a, const data* b) { return (a->tamanho < b->tamanho); } int main() { std::vector<data*> mesas; data x1, x2, x3, x4, x5; x1.indice = 1; x1.tamanho = 3; x2.indice = 2; x2.tamanho = 5; x3.indice = 3; x3.tamanho = 2; x4.indice = 4; x4.tamanho = 6; x5.indice = 5; x5.tamanho = 4; mesas.push_back(&x1); mesas.push_back(&x2); mesas.push_back(&x3); mesas.push_back(&x4); mesas.push_back(&x5); make_heap(mesas.begin(), mesas.end(), comparator2); for(int i = 0 ; i < 5 ; i++) { data* mesa = mesas.front(); pop_heap(mesas.begin(),mesas.end()); mesas.pop_back(); printf("%d, %d\n", mesa->indice, mesa->tamanho); } return 0; }; and this is what i get: 4, 6 2, 5 1, 3 3, 2 5, 4 So it's not working as a heap, as the maximum element on the vector is not being returned right. Or am i doing something wrong?

    Read the article

  • Is it a good idea to create an STL iterator which is noncopyable?

    - by BillyONeal
    Most of the time, STL iterators are CopyConstructable, because several STL algorithms require this to improve performance, such as std::sort. However, I've been working on a pet project to wrap the FindXFile API (previously asked about), but the problem is it's impossible to implement a copyable iterator around this API. A find handle cannot be duplicated by any means -- DuplicateHandle specifically forbids passing handles to it. And if you just maintain a reference count to the find handle, then a single increment by any copy results in an increment of all copies -- clearly that is not what a copy constructed iterator is supposed to do. Since I can't satisfy the traditional copy constructible requirement for iterators here, is it even worth trying to create an "STL style" iterator? On one hand, creating some other enumeration method is going to not fall into normal STL conventions, but on the other, following STL conventions are going to confuse users of this iterator if they try to CopyConstruct it later. Which is the lesser of two evils?

    Read the article

  • What is the right approach when using STL container for median calculation?

    - by sharkin
    Let's say I need to retrieve the median from a sequence of 1000000 random numeric values. If using anything but STL::list, I have no (built-in) way to sort sequence for median calculation. If using STL::list, I can't randomly access values to retrieve middle (median) of sorted sequence. Is it better to implement sorting myself and go with e.g. STL::vector, or is it better to use STL::list and use STL::list::iterator to for-loop-walk to the median value? The latter seems less overheadish, but also feels more ugly.. Or are there more and better alternatives for me?

    Read the article

  • Bewildering SegFault involving STL sort algorithm.

    - by just_wes
    Hello everybody, I am completely perplexed at a seg fault that I seem to be creating. I have: vector<unsigned int> words; and global variable string input; I define my custom compare function: bool wordncompare(unsigned int f, unsigned int s) { int n = k; while (((f < input.size()) && (s < input.size())) && (input[f] == input[s])) { if ((input[f] == ' ') && (--n == 0)) { return false; } f++; s++; } return true; } When I run the code: sort(words.begin(), words.end()); The program exits smoothly. However, when I run the code: sort(words.begin(), words.end(), wordncompare); I generate a SegFault deep within the STL. The GDB back-trace code looks like this: #0 0x00007ffff7b79893 in std::string::size() const () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/libstdc++.so.6 #1 0x0000000000400f3f in wordncompare (f=90, s=0) at text_gen2.cpp:40 #2 0x000000000040188d in std::__unguarded_linear_insert<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, unsigned int, bool (*)(unsigned int, unsigned int)> (__last=..., __val=90, __comp=0x400edc <wordncompare(unsigned int, unsigned int)>) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1735 #3 0x00000000004018df in std::__unguarded_insertion_sort<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, bool (*)(unsigned int, unsigned int)> (__first=..., __last=..., __comp=0x400edc <wordncompare(unsigned int, unsigned int)>) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1812 #4 0x0000000000402562 in std::__final_insertion_sort<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, bool (*)(unsigned int, unsigned int)> (__first=..., __last=..., __comp=0x400edc <wordncompare(unsigned int, unsigned int)>) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1845 #5 0x0000000000402c20 in std::sort<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, bool (*)(unsigned int, unsigned int)> (__first=..., __last=..., __comp=0x400edc <wordncompare(unsigned int, unsigned int)>) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4822 #6 0x00000000004012d2 in main (argc=1, args=0x7fffffffe0b8) at text_gen2.cpp:70 I have similar code in another program, but in that program I am using a vector instead of vector. For the life of me I can't figure out what I'm doing wrong. Thanks!

    Read the article

  • c++ stl priority queue insert bad_alloc exception

    - by bsg
    Hi, I am working on a query processor that reads in long lists of document id's from memory and looks for matching id's. When it finds one, it creates a DOC struct containing the docid (an int) and the document's rank (a double) and pushes it on to a priority queue. My problem is that when the word(s) searched for has a long list, when I try to push the DOC on to the queue, I get the following exception: Unhandled exception at 0x7c812afb in QueryProcessor.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012ee88.. When the word has a short list, it works fine. I tried pushing DOC's onto the queue in several places in my code, and they all work until a certain line; after that, I get the above error. I am completely at a loss as to what is wrong because the longest list read in is less than 1 MB and I free all memory that I allocate. Why should there suddenly be a bad_alloc exception when I try to push a DOC onto a queue that has a capacity to hold it (I used a vector with enough space reserved as the underlying data structure for the priority queue)? I know that questions like this are almost impossible to answer without seeing all the code, but it's too long to post here. I'm putting as much as I can and am anxiously hoping that someone can give me an answer, because I am at my wits' end. The NextGEQ function is too long to put here, but it reads a list of compressed blocks of docids block by block. That is, if it sees that the lastdocid in the block (in a separate list) is larger than the docid passed in, it decompresses the block and searches until it finds the right one. If it sees that it was already decompressed, it just searches. Below, when I call the function the first time, it decompresses a block and finds the docid; the push onto the queue after that works. The second time, it doesn't even need to decompress; that is, no new memory is allocated, but after that time, pushing on to the queue gives a bad_alloc error. struct DOC{ long int docid; long double rank; public: DOC() { docid = 0; rank = 0.0; } DOC(int num, double ranking) { docid = num; rank = ranking; } bool operator>( const DOC & d ) const { return rank > d.rank; } bool operator<( const DOC & d ) const { return rank < d.rank; } }; struct listnode{ int* metapointer; int* blockpointer; int docposition; int frequency; int numberdocs; int* iquery; listnode* nextnode; }; void QUERYMANAGER::SubmitQuery(char *query){ vector<DOC> docvec; docvec.reserve(20); DOC doct; //create a priority queue to use as a min-heap to store the documents and rankings; //although the priority queue uses the heap as its underlying data structure, //I found it easier to use the STL priority queue implementation priority_queue<DOC, vector<DOC>,std::greater<DOC>> q(docvec.begin(), docvec.end()); q.push(doct); //do some processing here; startlist is a pointer to a listnode struct that starts the //linked list cout << "Opening lists:" << endl; //point the linked list start pointer to the node returned by the OpenList method startlist = &OpenList(value); listnode* minpointer; q.push(doct); //more processing here; else{ //start by finding the first docid in the shortest list int i = 0; q.push(doct); num = NextGEQ(0, *startlist); q.push(doct); while(num != -1) cout << "finding nextGEQ from shortest list" << endl; q.push(doct); //the is where the problem starts - every previous q.push(doct) works; the one after //NextGEQ(num +1, *startlist) gives the bad_alloc error num = NextGEQ(num + 1, *startlist); q.push(doct); //if you didn't break out of the loop; i.e., all lists contain a matching docid, //calculate the document's rank; if it's one of the top 20, create a struct //containing the docid and the rank and add it to the priority queue if(!loop) { cout << "found match" << endl; if(num < 0) { cout << "reached end of list" << endl; //reached the end of the shortest list; close the list CloseList(startlist); break; } rank = calculateRanking(table, num); try{ //if the heap is not full, create a DOC struct with the docid and //rank and add it to the heap if(q.size() < 20) { doc.docid = num; doc.rank = rank; q.push(doct); q.push(doc); } } catch (exception& e) { cout << e.what() << endl; } } } Thank you very much, bsg.

    Read the article

  • Design approach, string table data, variables, stl memory usage

    - by howieh
    I have an old structure class like this: typedef vector<vector<string>> VARTYPE_T; which works as a single variable. This variable can hold from one value over a list to data like a table. Most values are long,double, string or double [3] for coordinates (x,y,z). I just convert them as needed. The variables are managed in a map like this : map<string,VARTYPE_T *> where the string holds the variable name. Sure, they are wrapped in classes. Also i have a tree of nodes, where each node can hold one of these variablemaps. Using VS 2008 SP1 for this, i detect a lot of memory fragmentation. Checking against the stlport, stlport seemed to be faster (20% ) and uses lesser memory (30%, for my test cases). So the question is: What is the best implementation to solve this requirement with fast an properly used memory ? Should i write an own allocator like a pool allocator. How would you do this ? Thanks in advance, Howie

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >