New answers tagged

0 votes

Calculating the sum of all k-sized sub-arrays in an array using sliding window algorithm

A short review; You use var for the function, I would use const, actually I would just use ...
konijn's user avatar
  • 32.9k
1 vote

Automation of array allocation in C

There's no way to enable the logging without modifying the header. Consider allowing VARRAY_DISPLAYDEBUG to be set before inclusion (to enable for specific ...
Toby Speight's user avatar
3 votes

C++20 "FixedArray" Container (dynamically allocated fixed-size array)

G. Sliepen's answer covers some good ideas already, but here are some additional points. Memory leak: Exception safety If a T has a constructor that throws, and a constructor does throw in the loop of ...
Urausgeruhtkin's user avatar
1 vote

Calculating the sum of all k-sized sub-arrays in an array using sliding window algorithm

Generally, LGTM. That said, It unclear what should happen if k > arr,length. In any case, better test it before entering the first loop. If the sliding window ...
vnp's user avatar
  • 55.5k
3 votes

Counting duplicate elements in two sorted arrays

The first thing I notice about the single function presented is the lack of a doc comment. Then again it is private, and readable enough I think I get what it does, ...
greybeard's user avatar
  • 5,929
4 votes

Counting duplicate elements in two sorted arrays

Looks good and correct, I'd have only two suggestions: Your function is called _find_Duplicates but it actually counts them, so ...
Marvin's user avatar
  • 560
1 vote
Accepted

Reusable storage for array of objects V3

Incorrect pointer used to construct objects You are constructing the objects using the non-aligned pointer. Use the pointer returned from new to destruct the ...
G. Sliepen's user avatar
  • 49.4k
2 votes
Accepted

Reusable storage for array of objects V2

Consider using or reimplementing std::any ...
G. Sliepen's user avatar
  • 49.4k

Top 50 recent answers are included