Jelajahi Sumber

Added warnings for pushConstruct methods in List.

David Piuva 7 bulan lalu
induk
melakukan
13db42a4bf
1 mengubah file dengan 4 tambahan dan 0 penghapusan
  1. 4 0
      Source/DFPSR/collection/List.h

+ 4 - 0
Source/DFPSR/collection/List.h

@@ -230,6 +230,8 @@ public:
 	}
 	}
 	// Side-effect: Pushes a new element constructed using the given arguments.
 	// Side-effect: Pushes a new element constructed using the given arguments.
 	//   Warning! Reallocation may invalidate old pointers and references to elements in the replaced buffer.
 	//   Warning! Reallocation may invalidate old pointers and references to elements in the replaced buffer.
+	//   Warning! Do not pass an element in the list as an argument to the constructor,
+	//     because reallocating will move the data from that location before being sent to the constructor.
 	// Post-condition: Returns a reference to the new element in the list.
 	// Post-condition: Returns a reference to the new element in the list.
 	template<typename... ARGS>
 	template<typename... ARGS>
 	T& pushConstruct(ARGS&&... args) {
 	T& pushConstruct(ARGS&&... args) {
@@ -240,6 +242,8 @@ public:
 	}
 	}
 	// Side-effect: Pushes a new element constructed using the given arguments.
 	// Side-effect: Pushes a new element constructed using the given arguments.
 	//   Warning! Reallocation may invalidate old pointers and references to elements in the replaced buffer.
 	//   Warning! Reallocation may invalidate old pointers and references to elements in the replaced buffer.
+	//   Warning! Do not pass an element in the list as an argument to the constructor,
+	//     because reallocating will move the data from that location before being sent to the constructor.
 	// Post-condition: Returns an index to the new element in the list.
 	// Post-condition: Returns an index to the new element in the list.
 	template<typename... ARGS>
 	template<typename... ARGS>
 	intptr_t pushConstructGetIndex(ARGS&&... args) {
 	intptr_t pushConstructGetIndex(ARGS&&... args) {