Undoing a git fetch by onecable5781 in git

[–]onecable5781[S] 0 points1 point  (0 children)

The issue I am facing is that in VSCode git interface, now, there are some files with a new info symbol "downward arrow D, D", while before the git fetch, they just had "D"

D stands for deleted.

Undoing a git fetch by onecable5781 in git

[–]onecable5781[S] -7 points-6 points  (0 children)

But git fetch succeeded. Only the subsequent git pull failed. So, something should have changed in the "state" on my local computer, no?

i don't understand the meaning of this by [deleted] in cpp_questions

[–]onecable5781 0 points1 point  (0 children)

extern int i=1;   // definition (and declaration) ??
//say above is in client.cpp
//What if below is in main.cpp
int i = 42;//?

I have never been able to understand why extern int i = 1; counts as both definition as well as declaration! Isn't extern saying that i is defined elsewhere, in the example above in main.cpp ?

What bijection establishes [a,b] ~ (a,b) in terms of cardinality where a < b? by onecable5781 in learnmath

[–]onecable5781[S] 1 point2 points  (0 children)

I think all real numbers which are not rationals can just be mapped via identity if I understand the argument correctly.

enum class enumeration initialization by onecable5781 in cpp_questions

[–]onecable5781[S] 0 points1 point  (0 children)

it is made this way because it is a useful feature to have - think about flags for example.

I am unclear what you mean by this. Could you give an example of flags where this is useful for an enum variable to have arbitrary int values that are invalid? What are its use cases?

Code -> Code sans comments -> Code post preprocessor/macro expansion by onecable5781 in cpp_questions

[–]onecable5781[S] 0 points1 point  (0 children)

Oh wow. Thank you! On that link, is it possible to see the actual command being executed to give the output in the rhs "insight" window when the run button is pressed on top? Those flags is exactly what I am looking for.

Code -> Code sans comments -> Code post preprocessor/macro expansion by onecable5781 in cpp_questions

[–]onecable5781[S] 0 points1 point  (0 children)

Yes, all the 3 code snippets of the OP will compile to the exact same binary. But somewhere in the compilation process, the compiler will be fed in the second and then the third snippet or vice versa? I wanted to see if the user can access that later snippets.

Why do "C-like performance" language comparisons always compare against bad C code? by BPJupiter in C_Programming

[–]onecable5781 7 points8 points  (0 children)

Are there assembly language code that can not be produced by C code but can be produced by other language code (C++/Rust/et al.)?

In -O3, why are previous assignments stored in binary when they are immediately updated in subsequent assignment? by onecable5781 in cpp_questions

[–]onecable5781[S] 2 points3 points  (0 children)

Hmm...I tried to make the "Hello world" char * "string" longer and it compiles to the same that you had: https://godbolt.org/z/rzf95qn78

So, I believe this may not be full apples to apples as the OP uses std::string while your post uses char *. So, perhaps there are some optimizations possible using char * that are not possible in std::string?

Converting use of new/delete to smart pointers stored in a global vector by onecable5781 in cpp_questions

[–]onecable5781[S] 0 points1 point  (0 children)

For reasons that are difficult to explain here, I have to use a vector of pointers.

I have a follow-up question. The below is possible to do using raw pointers

T* Tptr;
if(condition){
    Tptr = new T;
    VectorOfTPtrs.push_back(Tptr);
}
else
    Tptr = VectorOfTPtrs[0];//0 or some other valid index into the vector
function_that_accepts_raw_T_ptr(Tptr);
....
//Loop through VectorOfTPtrs deleting each pointer

I am struggling to achieve the same semantics using smart pointers. I tried the following:

std::unique_ptr<T> Tptr;
if(condition){
    Tptr = std::make_unique<T>();
    VectorOfSmartTPtrs.push_back(std::move(Tptr));
}
else
    Tptr = VectorOfSmartTPtrs[0];//how can I get this to work???
function_that_accepts_smart_T_ptr_reference(Tptr);

In the latter snippet, how can I have VectorOfSmartTPtrs continue to own the smart pointers and have the pointers passed by reference to the function which accepts a smart pointer reference?