CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: monarch_dodra

Page 1 of 80 1 2 3 4

Search: Search took 0.15 seconds.

  1. Replies
    7
    Views
    1,490

    Re: Template specialisation error

    That works, but the issue (I had) remains that we (I) can't extract "Args" back out from function_ptr (or signature).

    I've been able to extract the "T", but how do you implement operator()?


    ...
  2. Replies
    7
    Views
    1,490

    Re: Template specialisation error

    So, have you had much luck on your end finding a better solution?

    I'm pretty sure there could be ways for you to define the template in the form:
    function<std::function<args>, actual_function>...
  3. Replies
    7
    Views
    1,490

    Re: Template specialisation error

    Alternatively, you could use something such as function_traits to extract the arguments of your function pointer directly.
  4. Replies
    7
    Views
    1,490

    Re: Template specialisation error

    The issue is that you can only use "(void)" at syntax level, for C compatibility. But inside templates, you are way past that phase, and the compiler will not accept passing the *actual* void type.
    ...
  5. Replies
    1
    Views
    782

    Re: Generate Unique Ids

    Why not just use UUIDs?

    The advantage of UUID is there is no need to try to track consistency. You don't have to worry about threads, races, or multiple machines generating ids.

    Either that, or...
  6. Re: Read and write std::vector through stream

    As you wrote, you can read and write to a binary stream via the read and write functions.

    Just iterate over the vector, and write all elements 1 by 1. Same thing for reading back: just insert the...
  7. Re: memory alloc, access and release by 3 different functions

    Or alternatively, just return the pointer:



    unsigned short *alloc_mem()
    {
    unsigned short *input = (unsigned short *)calloc(SIZE, sizeof(unsigned short));
    input[0]=0xAABB;...
  8. Re: Add the ability to Search And Delete , in this AVL tree code

    If you don't store the height of a subtree in their corresponding root node, you are going to have catastrophic (insertion) performance. Right now, the calculation of the tree's height is O(n) where...
  9. Re: What will happen if I brutally force to stop an application when ptrs are smart

    Typically, everything is "freed", but not necessarily "cleanly". Files may not be flushed, temporary lock files may not be deleted, termination signals may not be sent etc...
  10. Replies
    11
    Views
    1,439

    Re: Some serious error

    I wouldn't really agree. When an allocation fails, there isn't really anything you can do about it most of the time, and are usually better off just letting the exception propagate.

    In particular,...
  11. Re: How to avoid an empty entry when an empty slot is found?

    Not to rant or anything, but you are close to 900 threads here over a span of 6 years. Surely you should know how to use a map by now? It's a super basic question, and one you've already asked too:...
  12. Re: How to avoid an empty entry when an empty slot is found?

    +1 for find



    auto it = window.find(currentWindow);
    if (it != window.end()) {
    ...
    }
  13. Replies
    6
    Views
    1,204

    Re: Genetic Algorithm - Crossover and MPI

    MPI is Message Passing Interface. It's a way of doing "multithreading" where threads communicate by sending messages to each other. Usually, these threads do not share any memory at all, which means...
  14. Replies
    20
    Views
    2,818

    Re: eof not working properly?

    FWIW, I've found that the issue with not using getline is that it often (wrongly) succeeds with badly structured files. You 'll sometimes end up reading data from multiple lines at once and/or...
  15. Replies
    20
    Views
    13,857

    Re: Sparse Matrix Operations

    I believe the original goal was to get this working for sparse matrix implementations?
  16. Replies
    4
    Views
    3,203

    Re: (Array Swapping Elements) Game Help

    Debugger depends a lot on what IDE you are using. But most IDEs have debugging integrated and work pretty much the same way. You first click on a line number, which will set a little red dot there,...
  17. Replies
    2
    Views
    797

    Re: Returning a smart pointer by value?

    This is the correct way to do it. Your pointer indeed gets trashed, but that's OK, since you are also returning a copy, so your reference count does not drop to 0 (unless your compiler implements...
  18. Re: Why is my struct destructor not called???

    If the double free/delete don't get you first ;)
  19. Re: How do I complete my code to shift array elements to the right?

    This approach creates binary bloat, and increases compile times. What you want to do is merely use the template interface to forward to a non-template interface.

    But even then, things like c++17's...
  20. Re: How do I complete my code to shift array elements to the right?

    you have non-matching signatures:
    void rightShiftElements (int arr[], int N);
    vs
    void rightShiftElements (int arr[], int N, int M)

    Also, you are calling it with the wrong name:
    shiftright(...
  21. Re: How to make a short form of copy constructor in the inherited class?

    No, that's wrong. That's A's (copy) constructor's job. By the time B's copy constructor is running, A is fully built and initialized. B cannot initialize A's fields.

    The only thing B's copy...
  22. Re: Appending Node to Doubly Linked List

    Also, just looked at your code again: One of the main points of a doubly linked list is backwards iteration and being able to access the last element easily. You should NOT be walking your list to...
  23. Re: Appending Node to Doubly Linked List

    I'd suggest you start by having a Node constructor that at the very least initializes your fields for you (especially the pointers). Better yet, use C++11's member initialiser.

    Anyways, a "pro...
  24. Replies
    2
    Views
    706

    Re: So Slow to clear an unordered map.

    hash_combine does hashing of whatever it is passed, so
    hash_combine(seed, k.x); should be fine.

    Regarding your original question: How exactly are you clearing the map, and how are you populating...
  25. Re: How to have a statement run in global scope in C++

    This is not accurate. mem_ob is not a "member object". It is just a local object that will be destroyed at the end of the scope of the constructor. What you want is:


    class MemTr {
    private:...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4





Click Here to Expand Forum to Full Width

Featured