volatile methods in C++
Wow, a feature of C++ i did not know, ‘volatile’ methods. Well, i’d say extremely rare one, but still.

Wow, a feature of C++ i did not know, ‘volatile’ methods. Well, i’d say extremely rare one, but still.

I wonder why memset is the only mean we have in libc in order to fill memory. We are limited to filling the memory with certain char. What if i want to use longer pattern? Is there anything like memset64? Generally, i’d like to fill the buffer with pattern which is 4 or 8 bytes long. I’m pretty sure, that’s the way memset is implemented anyway, for performance.
Maybe i’m missing something, but i was unable to find anything like this in the libc.
I’m currently rewriting some python code in c++, due to performance problems. I needed a simple parser and i found spirit which is part of boost. I must say wow WOW. I must learn boost. It’s simply great. While I’m pretty sure it will not be possible to use it at work due to conservative nature (with respect to code and tools) of the management here, it’ll surely give me some ideas
.
From time to time, when i remove redundant #include statements from our project, i wonder - is there an automatic tool to do this?
As a first step it’d be nice to have a tool which removes really redundant #includes - those which will not interfere with project build. As a second step - it’d be really nice to have suggestions to use forward declarations where possible instead of #includes.
For a small project the problem can be solved manually, but for a large one, with several build targets… well - automation is a must.
Any suggestions on such a tool?
Technorati Tags: c++, #include, programming
Just a reminder. C++ is not C. memset is a useful function (you know, take-memory-location-and-length-and-fill-it-with-char). But there’s no reason whatsoever to use it in order to reset an object. Define a Reset() method (or choose your own name) and use it.
I’m not just saying it. It’s coming from a frustrated person after looking for a memory bug for day and a half. The bug was memset which reset some variable which was used in other memset and reset a lot of memory this way.
Two lessons learned:
Technorati Tags: c++, c, memset, electric fence, efence
It’s something i have to remember from now on.
Technorati Tags: c++, oop, programming
Coming from a C++ programmer:
const checksobj.xxx = 12 and the real member variable name is Xxx it takes ages to find the problem Technorati Tags: python, c++, programming
I’m writing a genetic algorithm, which is pretty time consuming. I was thinking - why not use memoization and save some time. It appears pretty easy to do and there’re several examples for copy-paste in the internet, but it appeared that’s it not as simple as i thought it would be.
I’m trying to memoize (i’ll use cache from now) objects of a certain class. The class has some double precision data members, which i want to allow to be a little different, for example abs(self.a - rhs.a) < 0.1. It’s easy, just define __eq__ method. Now, let’s put objects into a dictionary (for caching)… oops - there’s an exception thrown - they are unhashable now.
Fast search in google revealed i need to define __hash__ method which must return equal results for equal objects…. Now it becomes non trivial at all.
In c++ it’s easy since std::map (stl equivalent of python’s dictonary) is based on operator< (or on comparison functor with the same functionality), and in python dictionary is based on hash value, which is faster but not easy calculable in my problem.
Is there something like std::map ready? Currently the solution was to round floating points members and cache them. Any better solutions?
Technorati Tags:
python, memoization, optimization, programming
Get free blog up and running in minutes with Blogsome
Theme designed by Gary Rogers