What does the tbb::scalable_allocator in Intel Threading Building Blocks actually do under the hood ?
It can certainly be effective. I've just used it to take 25% off an apps' execution time (and see an increase in CPU utilization from ~200% to 350% on a 4-core system) by changing a single std::vector<T> to std::vector<T,tbb::scalable_...
I'm trying to find a definitive answer and can't, so I'm hoping someone might know.
I'm developing a C++ app using GCC 4.x on Linux (32-bit OS). This app needs to be able to read files > 2GB in size.
I would really like to use iostream stuff vs. FILE pointers, but I can't find if the large file #defines (_LARGEFILE_SOURCE, _LARGEFILE6...
I just read in the C++ standard that std::for_each is a non-modifying sequence operation, along with find, search and so on. Does that mean that the function applied to each element should not modify them? Why is that? What could possibly go wrong?
Here is a sample code, where the sequence is modified. Can you see anything wrong with it...
I have written code that allows one to traverse mapped data in the order it was entered.
The solution I coded a couple of times was:
Given a keytype, K, and and data type, D,
std::map
std::vector
When one wanted to randomly find a data entry, use map.find(K). When one wanted to traverse the map in entry order, use std::vect...
As (hopefully) we all know, vector<bool> is totally broken and can't be treated as a c array. What is the best way to get this functionality?
So far, the ideas I have thought of are:
Use a vector<char> instead, or
Use a wrapper class and have vector<bool_wrapper>
How do you guys handle this problem? I need the c_array() functionality...
So, I wrote a bunch of code that accesses elements in an stl vector by index[], but now I need to copy just a chunk of the vector. It looks like vector.insert(pos, first, last) is the function I want... except I only have first and last as ints. Is there any nice way I can get an iterator to these values?
...
How does std::vector implement the management of the changing number of elements: Does it use realloc() function, or does it use a linked list?
Thanks.
...
Hello all,
I have
std::list<multimap<std::string,std::string>::iterator> >
Now i have new element:
multimap<std::string,std::string>::value_type aNewMmapValue("foo1","test")
I want to avoid the need to set temp multimap and do insert to the new element just to get its iterator back
so i could to push it back to the:
std::list<m...
How can I derive a class from cout so that, for example, writing to it
new_cout << "message";
would be equivalent to
cout << __FUNCTION__ << "message" << "end of message" << endl;
...
Is there anything wrong with pushing back a vector of vectors? like
typedef vector<Point> Polygon;
vector<Polygon> polys;
polys.push_back(some_poly);
All the elements in some_poly will be copied right?
I have a bug in my code and I can't seem to figure out what's wrong with it.
...
typedef struct temp
{
int a,b;
char *c;
temp(){ c = (char*)malloc(10);};
~temp(){free(c);};
}temp;
int main()
{
temp a;
list<temp> l1;
l1.push_back(a);
l1.clear();
return 0;
}
giving segmentation fault.
...
I need to remove elements with specific value from std::list. With the list<int> I used remove() method.
Now I have list<CMyClass> so I thought I should use remove_if() but it's predicate takes only one paramater - the element to be tested.
How do I write a function foo(const CMyClass &Bad) which removes from list all the elements equa...
I inherited from C++ STL container and add my own methods to it. The rationale was such that to the clients, it will look act a regular list, yet has application-specific methods they can readily be called.
This works fine, but I have read numerous posts about not inheriting from STL. Can someone provide a concrete advice of how I migh...
Hi, I have two vectors of floats and i want them to become one vector of Complex numbers. I'm stuck. I don't mind using iterators, but i am sure it'd be rediscovering the wheel i'm not informed about. Is my code leading me in the right direction?
typedef std::vector<float> CVFloat;
CVFloat vA, vB;
//fil vectors
typedef std::complex<CVFl...
If front () returns a reference and the container is empty what do I get, an undefined reference? Does it mean I need to check empty() before each front()?
...
I was writing an algorithm this morning and I ran into a curious situation. I have two std::maps. I want to perform a set intersection on the sets of the keys of each (to find which keys are common to both maps). At some point in the future, I think it's likely I'll also want to perform set subtraction here as well. Luckily, the STL ...
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html
According to that article STL isn't suited for game-development.
What are your thoughts about this ?
My current approach is this :
use STL, if leads to performance problems exchange with homebrew container (or allocator) (didn't come to it yet, but I'm not doing a high-...
Is there a reason why passing a reference to a STL map as const causes the [] operator to break? I get this compiler error (gcc 4.2) when I use const:
error: no match for ‘operator[]’ in
‘map[name]’
Here's the function prototype:
void func(const char ch, std::string &str, const std::map<std::string, std::string> &map);
And, I ...
I am trying to optimize a C++ routine. The main bottleneck in this routine is the push_back() of a vector of objects. I tried using a deque instead and even tried a list. But strangely (and contrary to theory) deque and list implementations run much slower than the vector counterpart.
In fact even clear() runs much slower for the deque ...
I like STL algorithms, and prefer use algorithms rather than usual loops.
Almost all STL algorithms are usually used as:
std::algorithm_name( container.begin(), container.end(), ..... )
container.begin(), container.end() - is one of most popular words pair in my projects.
Does anybody have the same problem?
How do you Guys solve ...