Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Also I don't see your code implementing the rule of three rule of three. This means that your objects will not work correctly if there are any copies made (and C++ makes copies all the time).

Also I don't see your code implementing the rule of three. This means that your objects will not work correctly if there are any copies made (and C++ makes copies all the time).

Also I don't see your code implementing the rule of three. This means that your objects will not work correctly if there are any copies made (and C++ makes copies all the time).

added 225 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341

I'm asking for rather hard, destructive critics and review. Sure.

Sure.

 Vector(Vector&& move) nothrow
 Vector& operator=(Vector&& move) nothrow
 void swap(Vector& other) nothrow

Also I don't see your code implementing the rule of three . This means that your objects will not work correctly if there are any copies made (and C++ makes copies all the time).

To implement the rule of three you need to implement the following three methods:

Vector(Vector const&);
Vector& operator=(Vector const&);
~Vector();

I'm asking for rather hard, destructive critics and review. Sure.

 Vector(Vector&& move) nothrow
 Vector& operator=(Vector&& move) nothrow
 void swap(Vector& other) nothrow

I'm asking for rather hard, destructive critics and review.

Sure.

 Vector(Vector&& move) nothrow
 Vector& operator=(Vector&& move) nothrow
 void swap(Vector& other) nothrow

Also I don't see your code implementing the rule of three . This means that your objects will not work correctly if there are any copies made (and C++ makes copies all the time).

To implement the rule of three you need to implement the following three methods:

Vector(Vector const&);
Vector& operator=(Vector const&);
~Vector();
deleted 4 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341

###Things I don't see I don't see any move semantics for your class.

Normally (since C++11) I would expect containers to implement move semantics. i.e. I would expect to see the following methods:

 Vector(Vector&& move) nothrow
 Vector& operator=(Vector&& move) nothrow
 void swap(Vector& other) nothrow

The fact that you are special casing 1 and 2 makes me suspecioussuspicious that there is underlying error you are trying to correct for.

parent = (child-1)/2 // 0 1 2
leftC = parent*2 + 1 // 1 3 5
rightC = parent*2 + 2 // 2 4 6

The fact that you are special casing 1 and 2 makes me suspecious that there is underlying error you are trying to correct for.

parent = (child-1)/2

###Things I don't see I don't see any move semantics for your class.

Normally (since C++11) I would expect containers to implement move semantics. i.e. I would expect to see the following methods:

 Vector(Vector&& move) nothrow
 Vector& operator=(Vector&& move) nothrow
 void swap(Vector& other) nothrow

The fact that you are special casing 1 and 2 makes me suspicious that there is underlying error you are trying to correct for.

parent = (child-1)/2 // 0 1 2
leftC = parent*2 + 1 // 1 3 5
rightC = parent*2 + 2 // 2 4 6
deleted 4 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
added 1092 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /