« first day (1320 days earlier)      last day (1516 days later) » 

2:53 AM
@ratchetfreak Because of this preprocesses my result file got changed on Windows plateform compare to the linux
 
 
6 hours later…
nwp
8:38 AM
@SAJW Depends on what you want to do. The throw; makes it so the caught exception is thrown again. So you print out the exception and then the exception continues to propagate until it is caught again or kills the program. This is normally used to do some sort of cleanup in after an exception is thrown (in this case printing) without actually handling the exception.
So if the catch actually handles the exception you don't throw;.
 
9:02 AM
@AmanJaiswal then run both through a formatter or use a dif tool that ignores whitespace
 
 
8 hours later…
5:03 PM
I'm a bit confused about how to use an outer/inner class. How can I access members of the outer class from the inner class? Is the only way to provide some kind of reference in the inner class's constructor to the outer class?
And if so, then how can the outer class call anything from the inner class. It seems like I might need some kind of forward declaration but I'm not sure how to handle it.
 
@TylerShellberg just because the types are "below each other" in a hierachy doesn't mean that the instances of those types have any relation
you can easily imagine making an object of the inner type without an instance of the outer, what would you do then if you could just access the outer types non-static fields?
 
So just because Outer::Inner exists, does not mean an instance of an outer has an instance of the inner? That much makes sense.
So If I do need a reference to the outer instance, but the outer needs to call something from the inner, what do I do? Is forward declaration of the inner the only option?
Fwd decl. never seem to work out well for me
 
either you need to full declaration or you make it a bit indirect, i.e. with a unique_ptr<Inner>
 
What do you mean a "full declaration"?
 
the compiler needs to know how large the object is, if you want to use it by value
 
5:09 PM
Right now I have the declaration of inner inside the declaration of outer, inside some header file. And the implementation of both is in a .cpp file.
 
right, then there shouldn't be any trouble
 
I guess I'll just need to move the declaration of inner to the top of the declaration of outer instead of towards the bottom
darnit that doesn't work either
see if I move it to the top, then the inner class can't see the definition of the types it uses from the outer class
but if it's on the bottom, then the inner class doesn't know what a reference to the inner would look like
so I can't do either
 
not what precisely you mean by using types from the outer class, but the option is always there to use some indirection like I mentioned
i.e. don't store it by value but by a pointer/smart-ptr to it
 
How would pointer fix it if reference doesn't work?
b/c compiler always knows the size of a pointer?
but reference should be the same deal, shouldn't it?
 
yeah, references are the same
It's really hard to know what you're talking about without specifics
 
5:16 PM
the classes are large and I can't exactly copy-paste them somewhere to show
Sorry
 
then reduce it to a minimal sample that still exhibits the problem
 
I think I've fixed most of it with a forward declaration. However, trying to call the inner class' constructor (which takes a reference to the outer class) doesn't work. Says that the copy assignment operator is implicitly deleted and "Copy assignment operator of InnerClass is implicitly deleted because field is of type Const OuterClass&"
Making the inner class' reference to the outer non-const didn't help unfortunately
 
@TylerShellberg so initialize the reference in the initializer-list of the InnerClass instead
 
I already did
that's what I'm doing now
which is why the error is kind of odd
 
5:33 PM
most modern compilers give you enough context afterwards in the error output to see which construct requested the copy
 
Decided to try using a unique_ptr<Inner> instead for the outer class. Seems to work now.
Thank you for that suggestion.
It looks like I can't do delete on a unique_ptr though, so I'll need to figure out how that all gets cleaned up
Oh, apparently that's the point of unique_ptr, it cleans it up for you once that pointer is out of scope?
 
6:03 PM
@TylerShellberg Once the unique_ptr object goes out of scope, yes.
 
thanks
 
6:26 PM
@PeterT is that a guarantee made by C++?
 
6:50 PM
Yes, both C and C++ guarantee it. It's why the operators && and || are said to have short-circuit evaluation
 
 
2 hours later…
8:58 PM
if I delcare a variable, should that always happen at the start of the function? (not "i" from for-loops)
 
@SAJW You should generally declare the variable as close to where you'll use it as possible.
 

« first day (1320 days earlier)      last day (1516 days later) »