Sure, that works too.
I'm familiar with the method presented by Marshall Kline, too.
I'm just trying to understand what needs to go in the auxiliary header and what can be in the source file, if I...
Type: Posts; User: krappa
Sure, that works too.
I'm familiar with the method presented by Marshall Kline, too.
I'm just trying to understand what needs to go in the auxiliary header and what can be in the source file, if I...
Hi,
I usually separate template class definitions in 3 files, a .h for declaration, a .cpp for method definition and a .hpp for "template-dependent" method definitions. Standard procedure.
I...
Great! That's the thing I was looking for.
Works like a charm.
Thanks laserlight.
Hmm, I still don't get it.
Foo isn't a class template, it's a normal class with two function templates.
Using your solution above, I'm going to have to instantiate Foo/Myclass specifying the...
I don't quite get where you would want me to use "myclass". As a member of Foo, or as replacement for Foo?
Case 1: Is that going to change anything, since map is already a template class? Isn't...
Hi,
There's probably a simple way to get rid of this, but I just can't find it.
I have a class with two function templates. One of them calls the other, and the other one is defined with...
Because of the first_choice++, first_choice will have been incremented when it gets to the switch statement, so:
x + first_choice = 0 + 1 = 1
That's pretty much what I ended up doing.
Still, If someone knows of a way to do this implicitly, let me know.
It is called, but it isn't called explicitly.
The different implementations call the manager to register themselves.
And the manager accesses them agnostically, using the abstract interface.
...
You've probably heard that an array is actually a pointer to the first element of your array.
A multi-dimensional array, is actually an array of arrays (or an array of pointers).
What happens is...
I got the answer:
The declaration of DirectSoundApi is inside a static library, while AsioApi is in the current project. Since there is no explicit reference to DirectSoundApi, it is not linked.
...
The only major difference is that AudioDevice_DirectSound.cpp contains a lot of Windows/DirectX includes and code which might influence the compilation in a way I haven't thought of.
Also, if I...
Yes, I am linking. Yes, it is very strange.
There are no explicit calls to my global API objects. Could it be optimization that removes this instance ?
I have a number of static members of classes interacting. One of them never gets initialized.
I am trying to implement an common interface for audio devices, whatever the API. I register all APIs...
Even so, a struct doesn't contain functions. (Pointer to functions at best, but that's for another day).
Anyway, this code is valid, if you use C++. Rename your file .cpp and feed it to gcc (or g++,...
Thanks for trying it out, anon!
Thanks for pointing that out. The sizeof(Test) is 1, yet new (pool, Wrapper,Test>()) Test[n] calls the new operator with size n+4, due to 4-byte alignment. In...
The goal of this memory pool is to have cheap allocations by just incrementing a pointer. Having to create an object, then copy it, then destroy the original would pretty much contravene the original...
True.
Indeed. The Clear method requires to keep the pointer to the first allocated object. I made a helper class, nuiMemoryPoolGuard, to that effect. It just keeps the pointer at the moment...
The Dtor knows the size of Type1, Type2, because of the template.
When I want to clear the pool, I rewind the current memory pointer by sizeof(DtorType), the pointer now points to a pointer to a...
That's the point of having the Dtor function return the freed memory pointer. Any time a call a Dtor, I can update my pointer to be right after the next Dtor. I can roll back object destructors one...
I use uint8* because I'm considering the memory as a field of bytes. It's not a good approach, I'll grant you that.
I started out using void*, but you can't perform arithmetic on void*. So I...
So since I didn't have the destructor, I decided to wrap the destruction in a static template function:
typedef uint8* (*DtorType)(uint8*);
template <class T> uint8* Dtor(uint8* pToDelete)...
Actually, this isn't the right syntax. The pool is still work in progress, so I wasn't clear where to put some stuff.
Basically, I'm storing a pointer to the destructor of the new object so that I...
That's pretty much it. Except I don't want the MemoryPool to be fixed to only one type.
Is there any other way to get type information inside the new definition?
That works only in the non-templated case. If the new operator and MemoryPool::Allocate don't use templates, this works like a charm.
If I use the templated version and call:
sometype *p =...