« first day (200 days earlier)      last day (4738 days later) » 

10:00 PM
@StackedCrooked Funny, your answer appears above my statement here... am I the only one?
 
@FredOverflow He edited previous message. :P
 
@FredOverflow I answered inside my edit. Doh!
 
And if I have these vector int A[3]={0,0,0} and B[3]={1,2,3}, if I want A to be {1, 2, 3} it will be memcpy (A,B,3*sizeof(int)) right?
 
Yes or memcpy(A, B, sizeof A) instead.
 
10:05 PM
@Sword22 Yes. I think that A = B; will also work in your case.
 
You cannot assign arrays.
 
But, it works D:
 
No, it doesn't. It won't compile. g++ complains with error: invalid array assignment.
 
If you have arrays with size known at compile time, then you can do sizeof(a) / sizeof(a[0]) to get element count.
 
Ah ok you were answering to StackCrooked (?)
 
10:07 PM
Ah, OK. But if it's a member of a class then automatically generated assignment operator will work.
 
Though yeah, sizeof(a) is enough for memcpy/memmove.
 
@CatPlusPlus But why would you want to in the context of memcpy?
 
@CatPlusPlus That's the safest way because it will still work when the type changes. (Read that in the Google C++ style guide.)
 
@StackedCrooked Yes:
 
@FredOverflow It's late and I'm catching only certain parts of the chat messages. :P
 
10:08 PM
5
Q: How are C array members handled in copy control functions?

FredOverflowThis is something I have wondered for a long time. Take the following example: struct matrix { float data[16]; }; I know what the default constructor and destructor do in this specific example (nothing), but what about the copy constructor and the copy assignment operator? struct matrix {...

 
@StackedCrooked In C++ you can use boost::array which remembers its size.
 
@FredOverflow This is illustrated in the first chapter of "Exceptional C++" if I remember well..
 
@StackedCrooked I prefer sizeof a/sizeof*a, because this looks more hideous and makes me want to refactor arrays to vectors.
 
@CatPlusPlus Could be, not familiar with that.
@FredOverflow If that's your thing.. Alright ;)
 
10:11 PM
@StackedCrooked Ugly things should look ugly. That's one reason why const_cast & co. were introduced. It's too easy to glance over a C style cast.
 
@FredOverflow Arrays retain more compile time info that vectors though :)
 
It has iterators, bounds checking, supports assignment, remembers the size and is easily convertible to a raw array if needed. No reason not to use it.
 
@FredOverflow In case you need that...
 
@StackedCrooked Sooner or later, you'll probably want some runtime information, though. Arrays really suck at that.
 
@FredOverflow Compile time info is also available at runtime.
 
10:13 PM
Oh, and overloads comparison operators.
 
@CatPlusPlus Niceness.
 
@StackedCrooked Yes, but compile-time information is thrown out the window during array-to-pointer decay, which happens quite often.
 
@FredOverflow Well, I also prefer vectors. So there is no disagreement here :)
@FredOverflow Automatic array to pointer conversion is C's biggest mistake. (I believe that one of the authors of C actually said this in a recent interview.)
 
I agree.
 
@StackedCrooked It's definitely not helping newbies, I tell you! :)
 
10:16 PM
@CatPlusPlus If fixed-size is okay, I suggest using std::array<T, n> instead of T[n]. It has all the other benefits you listed.
 
@FredOverflow Yeah, I was talking about boost::array, I believe std::array is just that, or something based on boost::array.
 
@CatPlusPlus I know of no significant differences between boost::array and std::array.
 
BTW, is std::array in 0x, or was it just in TR1?
 
It was already in TR1.
So it will also be in 0x.
Is there anything in TR1 that is not in 0x?
 
Well, I don't know, that's why I'm asking. :P
I should be sleeping, but there's still work to do for tomorrow. Sucks.
 
10:22 PM
> The new standard will include several additions to the core language and will extend the C++ standard library, incorporating most of the C++ Technical Report 1 (TR1) libraries — most likely with the exception of the library of mathematical special functions.
 
10:32 PM
g2g, thank for your help guys you were really helpful !
 
 
1 hour later…
11:47 PM
Happy May Fourth Everybody!
 
hello everyone
 

« first day (200 days earlier)      last day (4738 days later) »