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

Search:

Type: Posts; User: wolle

Page 1 of 28 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    5
    Views
    111

    Re: Sudden problem with std::vector

    But, it only works if the function itself is executable at compile-time. If not, you still need to use an std::vector.
  2. Replies
    5
    Views
    111

    Re: Sudden problem with std::vector

    It will work (in this case) if the function is declared constexpr.
  3. Replies
    4
    Views
    530

    Re: Float point number simple arithmetic.

    In addition to my post #4.

    Not all decimal numbers have a finite digital representation. This includes 0.1, which requires an infinite number of bits. So when you assign 0.1 to a single-precision...
  4. Replies
    4
    Views
    530

    Re: Float point number simple arithmetic.

    A single-precision FP has 6-7 significant decimal digits, and a double-precision FP has 15-18. A good rule is to consider the significant digits only. The range of significant digits in an FP starts...
  5. Re: Why is my single thread code is faster than my multhread code?

    That may speed things up on the CPU side, but you probably should do something to that effect on the GPU side too. Maybe by pooling the command buffers,
    ...
  6. Re: Is it safe to locally use arrays, vectors and calloc when multi-threading

    I understand there may be company restrictions. But if you are free to choose, I recommend you update to the latest Visual Studio version and the latest C++ standard. With a reasonable delay, of...
  7. Re: Is it safe to locally use arrays, vectors and calloc when multi-threading

    I agree with the previous posters, at least if you use C++ version 11 or later.

    C++ 11 was a game-changer. Especially concurrency got a much-needed overhaul. Why should you not be able to use...
  8. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    861

    Re: Finding Doubles

    I posted a solution strategy to this problem quite some time ago now,

    https://forums.codeguru.com/showthread.php?562663-Birthday-is-no-problem&highlight=birthday+problem

    Today, I can just...
  9. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    861

    Re: Finding Doubles

    Say you draw numbers at random from a range of equally likely numbers. At some point, all numbers have come up at least once. After that, all drawn numbers will be duplicates. With N numbers in the...
  10. Thread: Tutorials

    by wolle
    Replies
    8
    Views
    480

    Re: Tutorials

    The C++ guidelines may not fit the bill perfectly, but it does demonstrate modern C++ usage (according to Stroustrup and Sutter, two prominent figures in the evolution of C++),
    ...
  11. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    861

    Re: Finding Doubles

    Duplicity is a relative property between two entities. To compare the current entitity in a sequence with previous entities, one must store them somewhere. Unless, of course, duplicity is an...
  12. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    861

    Re: Finding Doubles

    Then I suggest you use an std::unordered_set,

    https://en.cppreference.com/w/cpp/container/unordered_set

    You insert each new random integer into the unordered_set using the insert function. You...
  13. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    861

    Re: Finding Doubles

    Maybe you mean duplicates? Do you want to avoid them? One method is to add each new random number to an std::vector after making sure it is not already in there. Another method is to add the random...
  14. Replies
    10
    Views
    793

    Re: wait .. no blocking

    I often use a thread-safe producer-consumer queue for this kind of situation. The producer thread pushes information on the queue and the consumer thread pops it, either by active polling or waiting...
  15. Thread: array of objects

    by wolle
    Replies
    14
    Views
    1,202

    Re: array of objects

    The problem is that MyClass is not copyable because of the heap-allocated array held by the arr-pointer. And, as mentioned in #11, it gets copied here (underlined),



    myThs[i] =...
  16. Replies
    4
    Views
    483

    Re: threads and function call

    The Add function itself is thread-safe in the sense that it is reentrant in the right way,

    https://en.wikipedia.org/wiki/Reentrancy_(computing)

    It means you can call it pretty much as you like...
  17. Re: Is there a function intended to split strings by a delimiter in VC++?

    Yes, I wish I had come up with it myself :).

    I found it in the answer here,

    https://stackoverflow.com/questions/48402558/how-to-split-a-stdstring-into-a-range-v3-of-stdstring-views
  18. Re: Is there a function intended to split strings by a delimiter in VC++?

    Even simpler still. I found a way to get rid of the temporary string.

    No string constructor accepts the loop variable e directly. But e can deliver the starting address and length of a char...
  19. Re: Is there a function intended to split strings by a delimiter in VC++?

    I guess we need to be patient. Rome wasn't built in one day!
  20. Re: Is there a function intended to split strings by a delimiter in VC++?

    The code in my post #4 is directly from cppreference.com so either they or VS 2019 has it wrong.

    Anyway, using your suggestion I got this to work in VS 2019 (latest download),



    #include...
  21. Re: Is there a function intended to split strings by a delimiter in VC++?

    C++ 20 has a new feature called ranges. It has a function for splitting called std::ranges::split_view,

    https://en.cppreference.com/w/cpp/ranges/split_view/split_view

    I tried the last part of...
  22. Replies
    3
    Views
    1,158

    Re: Intersecting number ranges

    This is my motivation for the reduction of the first set of parentheses in #2:

    Say you have two intervals [dbstart .. dbend] and [paramstart .. paramend] and want to know if they overlap.

    You...
  23. Replies
    8
    Views
    1,165

    Re: Stopping unnecessary style corrections

    Generally, I find VS 2019 a little too complex and invasive for my taste so I've contemplated switching to VS Code for quite some time.

    But now I see VS 2022 is on the brink of being released and ...
  24. Replies
    3
    Views
    1,158

    Re: Intersecting number ranges

    If you are allowed to use parentheses () you could "break out" dbend >= 19010101 and dbend = 0 and get the following:


    dbend >= 19010101 and (dbstart >= paramstart and dbend <= paramend or...
  25. Re: Exercises that programmers should do to avoid back and neck pain

    How do you recognize a programmer in a crowd?

    It's the fit-looking individual who's juggling the heavy reference manuals of today as easily as if they were teeny-weeny language descriptions from...
Results 1 to 25 of 687
Page 1 of 28 1 2 3 4





Click Here to Expand Forum to Full Width

Featured