« first day (3485 days earlier)      last day (1525 days later) » 

2:25 AM
@0x00004 Perhaps your compiler outsmarted you.
 
 
3 hours later…
5:03 AM
Game development community has a nice way of managing things. I have no downvotes in any of my questions but i m no longer able to ask a question.
 
 
2 hours later…
7:06 AM
@0x00004 this is a pointer so you dereference it to get a reference
but why a=ref does not do anything
 
 
1 hour later…
8:10 AM
@trollingchar could you please demonstrate that?
 
8:30 AM
this is of type SomeClass*, pointer to SomeClass, a pointer and a reference are just not the same
3183
Q: What are the differences between a pointer variable and a reference variable in C++?

prakashI know references are syntactic sugar, so code is easier to read and write. But what are the differences?

 
 
1 hour later…
9:34 AM
Is it normal for Perlin noise generator to use only 8 gradient vectors?
 
user92578
Depends on the noise dimension
 
user92578
Yeah 8 is normal then
 
9:51 AM
how to deal with repeating patterns and lines of zeros then?
 
user92578
Multiple octaves? Or could you be using the noise wrong?
 
10:05 AM
maybe really I should use multiple octaves
 
user92578
10:25 AM
lol yeah usually, a standard implementation repeats every integer
 
2:53 PM
@0x00004 You have no downvotes on any of your not deleted questions. All of your questions are taken into account when you encounter a question block, including those that are deleted.
If you need help listing those deleted questions so that you can try and improve them, just let me know.
 
3:33 PM
Today's joy: figure out the cause of a bug we get in release, but not in debug.
 
user92578
3:44 PM
regexp to find anything that looks like an uninitialized variable
 
@Tyyppi_77 I don't think I'll be able to do this, but maybe using one or two static analyser. It's an issue in our physics engine (ODE).
 
user92578
Oof :(
 
@Vaillancourt i deleted those because i no longer needed an answer and when i was deleting them there was no answer
 
4:01 PM
@0x00004 Yes, however they have downvotes on them. You may want to figure out of a good quality question, then undelete the question and edit it so that others could upvote it.
@Tyyppi_77 VS can spot some of those uninitialized variables, I think.
 
@Vaillancourt how would they upvote the old questions?
anyway if i get upvotes for any contribution in community would i be able to ask again?
@Vaillancourt sorry i didnt understand what you meant.
class SomeClass
    {
    public:
        SomeClass()
        {
            a = 5;
        }
        SomeClass(int l_a)
        {
            a = l_a;
        }

        SomeClass& operator=(const SomeClass &l_copy)
        {
            this->a = l_copy.a;
            return *this;
        }

        int a;
    };
    SomeClass a;

    SomeClass b;
 
@0x00004 They would upvote the the new content. When you edit/reopen a question, it is bumped to the top of the "active" question, and people read it. If it's quality content, maybe some will upvote it.
 
SomeClass a; SomeClass b; a = b;
 
@0x00004 There is no guarantee. I don't know the algorithm that prevents you from asking, or allows you to ask again, only SE devs know about it.
 
1)return *this;

2)SomeClass &ref=a;

3)а=ref;
this is wrong?
 
user92578
4:10 PM
What do those three cases mean?
 
@0x00004 I don't understand your question. What are those 1) 2) and 3)?
 
Sorry
operator=
 
yes?
 
after operator= returns *this is that whats happening?
 
user92578
Assignment operator returns a value to allow statements like if (auto myBoolComparableClass = doOperationThatMightFail()) { // use myBoolComparableClass }
 
4:14 PM
then ref and a point to the same memory location?
 
user92578
I'm still not sure what the question is
 
the question is how operator= works
 
user92578
When you assign to a new reference variable, the assignment operator is not invoked, since you just essentially assign the memory location
 
user92578
Just like MyClass* ptr = &myInstance doesn't invoke the assignment operator
 
what about when SomeClass a gets that &ref?
 
user92578
4:18 PM
Then you are assigning to an instance, and the operator gets called
 
user92578
Note that it's different from SomeClass a = ref, which invokes copy constructor I think...
 
copy constructor gets invoked only if function returns a value i think
 
user92578
Lol no, it gets invoked when a copy is made
 
user92578
godbolt.org/z/do4bBY Line 26 invokes copy constructor
 
user92578
Function returns often use copy elision which doesn't copy the value at all, so that's 100% wrong
 
user92578
4:21 PM
In C++20 we get guaranteed named variable copy elision, which makes copies even more rare
 
okay
So just clear the air out .
3) a = ref does invoke operator= one more time?
 
user92578
Yes
 
those 3 cases is whats happening when i write a=b
or a.operator=(b);
 
user92578
What three cases? That invokes the assignment operator, that's it
 
1)return *this;

2)SomeClass &ref=a;

3)а=ref;
 
4:28 PM
Hey its me again... quick question... i open a UI-Prefab and i see a small thin white outline which represents the choosen screen size... its always there... anyway to disable that thin outline ? When exactly does it show up ?
 
user92578
@0x00004 I don't understand what these are? Some random lines of code someone might expect? A callstack of operations that take place?
 
when we assign a=b operator= gets invoked; and this is whats happening : this->a=l_copy.a; return *this; then reference of *this gets to be created , i.e. SomeClass &ref=*this; then a gets that reference , i.e. a= ref. Am i wrong?
 
user92578
You are wrong.
 
user92578
The returned reference is discarded since you aren't using it
 
then what exactly is happening?
 
user92578
4:34 PM
a.operator=(b); then a->a = b.a;
 
user92578
Return value is ignored
 
user92578
SomeClass& c = (a = b); would store return *this, i.e. a into c
 
so return value is not ignored only in that case?
SomeClass &c= a;
 
user92578
It's also not ignored if you do if (a = b) { }, but that requires that SomeClass is convertible to bool
 
user92578
68
A: Why must the copy assignment operator return a reference/const reference?

Michael BurrStrictly speaking, the result of a copy assignment operator doesn't need to return a reference, though to mimic the default behavior the C++ compiler uses, it should return a non-const reference to the object that is assigned to (an implicitly generated copy assignment operator will return a non-...

 
4:39 PM
thanks)
 

« first day (3485 days earlier)      last day (1525 days later) »