Search:

Type: Posts; User: King Mir

Page 1 of 20 1 2 3 4

Search: Search took 0.04 seconds.

  1. The two parts you are missing is how to construct...

    The two parts you are missing is how to construct and destroy the string.

    To construct the string, you need to use placement new, wherein you pass the address of the future location of the string...
  2. No, you can't do this with macros, because macros...

    No, you can't do this with macros, because macros are evaluated before function definitions are evaluated.

    There are several facilities in c++ that allow choosing between a specialized behavior,...
  3. Replies
    5
    Views
    4,449

    C++ explicitly disallows expressions that...

    C++ explicitly disallows expressions that evaluate to indeterminate values, except for they types unsigned char and std::byte. You could say this is to allow other types to have trap representations,...
  4. Thread: cases in c++

    by King Mir
    Replies
    27
    Views
    16,597

    I suggested changing to an array because of all...

    I suggested changing to an array because of all the stylistic issues with the code, I felt that "Don't repeat yourself" was the most important one to point out. Also, I would expect not function...
  5. Thread: cases in c++

    by King Mir
    Replies
    27
    Views
    16,597

    Learn some c++! Read my first post in this...

    Learn some c++! Read my first post in this thread, and wherever you're trying to learn c++ from again.

    You can't just cobble together a bunch of code snippets other people give you, you need to...
  6. Thread: cases in c++

    by King Mir
    Replies
    27
    Views
    16,597

    I agree that the somewhere in the code, each...

    I agree that the somewhere in the code, each function should have a better name. But in naming the functions function1 to function5, sonicflare9 properly observed that there is something common about...
  7. Thread: cases in c++

    by King Mir
    Replies
    27
    Views
    16,597

    Ignoring for a moment all the horrible style,...

    Ignoring for a moment all the horrible style, over engineering, and "that's not doing what you think it's doing" problems, the specific big problem is functions.cpp lines 2 through 24, and...
  8. Replies
    5
    Views
    1,083

    2) All of the following initialize a char...

    2) All of the following initialize a char variable to 0:

    char a{};
    char b = '\0';
    char c = 0;
    char d = char();
    char e(0);
    char f('\0');
    char g{0};
    char h{'\0'};
  9. Replies
    5
    Views
    5,718

    Code is written once, and read many times. Easy...

    Code is written once, and read many times. Easy to understand variable names make code all the more easy to read. you don't want to be guessing what an abbreviation stands for when you look back at...
  10. Replies
    5
    Views
    5,718

    Firstly, you definitely need resize, not reserve....

    Firstly, you definitely need resize, not reserve. Resize will create an vector with that many elements, default initialized each element to '\0'. Reserve allocates memory, but you can't write to that...
  11. Replies
    6
    Views
    6,405

    No. This is actually for an emscripten project,...

    No. This is actually for an emscripten project, and the data is being stored as a virtual file system for a web browser.
  12. Replies
    6
    Views
    6,405

    I eventually found the target property...

    I eventually found the target property LINK_DEPENDS does what I need.
  13. Replies
    6
    Views
    6,405

    Nope, that adds targets, not files.

    Nope, that adds targets, not files.
  14. Replies
    6
    Views
    6,405

    Cmake file dependancy

    I have a cmake project. It has a target which as part of the linker step requires an additional file to be embedded in the "executable". I know how to pass in the linker flags to include the file,...
  15. Replies
    5
    Views
    4,446

    Display issues means your code compiles and are...

    Display issues means your code compiles and are therefore a sign of a different problem.


    What I'm suggesting is reversing this order.
  16. Replies
    5
    Views
    4,446

    It looks like you're using Display and Visual...

    It looks like you're using Display and Visual inside img.h, which is included in options.cpp. The correct thing to do here is to make img.h include the X11 headers it needs. You may also want to not...
  17. An acquire fence will prevent loads from being...

    An acquire fence will prevent loads from being moved before the fence, but will not prevent load from being moved bellow. So your code is equivalent to:

    for(;;)
    {
    __atomic_thread_fence(...
  18. Here's another possible order: writer ...

    Here's another possible order:


    writer reader
    ====== ======
    store c0
    store c1
    store barrier
    load barrier
    store c1
  19. Replies
    31
    Views
    24,130

    It is part of my attempt to explain why compilers...

    It is part of my attempt to explain why compilers can't ignore volatile qualifiers.

    It must honor volatile casts. Consider the following example: an interupt service routine(ISR) can in general...
  20. An atomic increment would indeed be more than...

    An atomic increment would indeed be more than just a move instruction. But a store to an atomic variable can be. Read-modify-write operations require either hardware support, or a spinlock. Like move...
  21. You don't need the sleep for a thread to be...

    You don't need the sleep for a thread to be launched in the background. Sleeps are used in exercises like this as a stand in for long running computations. Without the sleep it's difficult to see...
  22. Replies
    31
    Views
    24,130

    The compiler and processor are actually different...

    The compiler and processor are actually different in this case. C has a concept of volatile which the compiler must obey, because it signifies that changes may be external to the program. C has no...
  23. No, atomics can be an ordinary move, especially...

    No, atomics can be an ordinary move, especially on intell. In general an an atomic operation is a read and/or write that is preceded and/or succeeded by memory fences. See C/C++11 mappings to...
  24. Unfortunately, unlike with std::array, you can't...

    Unfortunately, unlike with std::array, you can't just replace all uses of "char *" with std::string, as the OP example demonstrates.

    Also, because string is a dynamically sized, it has costs that...
  25. Saying you should use std::array is well and...

    Saying you should use std::array is well and good, but doesn't help the problem here, because we're dealing with string literals. So understanding the intricacies here can be necessary. Often though,...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4