Search:

Type: Posts; User: krappa

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    949

    Sure, that works too. I'm familiar with the...

    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...
  2. Replies
    4
    Views
    949

    Need hints on templates

    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...
  3. Great! That's the thing I was looking for. Works...

    Great! That's the thing I was looking for.
    Works like a charm.

    Thanks laserlight.
  4. Hmm, I still don't get it. Foo isn't a class...

    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...
  5. I don't quite get where you would want me to use...

    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...
  6. Function template specialization and duplicate symbols

    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...
  7. Thread: C++ Question

    by krappa
    Replies
    3
    Views
    1,604

    Because of the first_choice++, first_choice will...

    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
  8. Replies
    10
    Views
    2,032

    That's pretty much what I ended up doing. ...

    That's pretty much what I ended up doing.

    Still, If someone knows of a way to do this implicitly, let me know.
  9. Replies
    10
    Views
    2,032

    It is called, but it isn't called explicitly. ...

    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.
    ...
  10. Replies
    4
    Views
    1,622

    You've probably heard that an array is actually a...

    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...
  11. Replies
    10
    Views
    2,032

    I got the answer: The declaration of...

    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.
    ...
  12. Replies
    10
    Views
    2,032

    The only major difference is that...

    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...
  13. Replies
    10
    Views
    2,032

    Yes, I am linking. Yes, it is very strange. ...

    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 ?
  14. Replies
    10
    Views
    2,032

    static object never inits

    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...
  15. Replies
    7
    Views
    1,403

    Even so, a struct doesn't contain functions....

    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++,...
  16. Replies
    40
    Views
    11,183

    Thanks for trying it out, anon! Thanks for...

    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...
  17. Replies
    40
    Views
    11,183

    The goal of this memory pool is to have cheap...

    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...
  18. Replies
    40
    Views
    11,183

    True. Indeed. The Clear method requires to...

    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...
  19. Replies
    40
    Views
    11,183

    The Dtor knows the size of Type1, Type2, because...

    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...
  20. Replies
    40
    Views
    11,183

    That's the point of having the Dtor function...

    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...
  21. Replies
    40
    Views
    11,183

    I use uint8* because I'm considering the memory...

    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...
  22. Replies
    40
    Views
    11,183

    So since I didn't have the destructor, I decided...

    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)...
  23. Replies
    40
    Views
    11,183

    Actually, this isn't the right syntax. The pool...

    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...
  24. Replies
    40
    Views
    11,183

    That's pretty much it. Except I don't want the...

    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?
  25. Replies
    40
    Views
    11,183

    That works only in the non-templated case. If the...

    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 =...
Results 1 to 25 of 53
Page 1 of 3 1 2 3