Quote:Original post by visitor
However do the compilers realize that the assignment is indeed trivial for user-defined types?
They should.
Quote:Original post by visitor
However do the compilers realize that the assignment is indeed trivial for user-defined types?
Quote:Original post by someboddy
I've just figured out that all those coping around could be a slowdown.
Quote:Original post by someboddy
Well, I have a 2D vector class, and a polygon class that has an array of that vector class. The polygon class gets copied around alot during the calculations, so I figured that to speed things up, I can {do more work, and I don't know yet if it will make a difference}
Quote:My vector class is a class, but there is nothing stopping me from making it a struct.
Quote:Also, the only critique in the POD definition that my vector class doesn't mach is having a constructor, but I only use the constructor to set the x and y values, so I don't think it should be such a problem...
Quote:Original post by someboddy
OK, so you all think I should leave those kind of optimizations to the compiler. but how does the compiler knows if a class is POD? The constructor is there for convenience, it doesn't initialize anything vital(ofcourse, not having rubbish data is quite vital, but you know what I mean...), but will the compiler realize this and treat it as a POD, or does it have a thumb rule - contructor==not POD? Is there a way to define to the compiler that a certain class is POD?
Quote:I tried to use the "is_pod" class to check if my vector class is POD, but it seems like I don't have the "type_traits" header. Where can I get that library?
Quote:
Alternatively boost have an implementation of that.
struct __type_traits { typedef __true_type this_dummy_member_must_be_first; typedef __false_type has_trivial_default_constructor; typedef __false_type has_trivial_copy_constructor; typedef __false_type has_trivial_assignment_operator; typedef __false_type has_trivial_destructor; typedef __false_type is_POD_type; };
Quote:Original post by visitor
It seems to me that boost only detects built-in types as POD (with MinGW 3.4.5)