New answers tagged

1

Readability The vector initialization in main would be more readable if the {{ and }} were broken out onto separate lines. vector<vector<int>> nums = { {1, 1, 1, 0, 0, 0}, // 0 {0, 1, 0, 0, 0, 0}, // 1 {1, 1, 1, 0, 0, 0}, // 2 {0, 0, 2, 4, 4, 0}, // 3 {0, 0, 0, 2, 0, 0}, // 4 {0, 0, 1, 2, 4, 0}...


1

I would recommend marking explicit the conversions that could truncate values (e.g. construction from another short string, with N > Size). Almost every function assumes that the string ends at the first NUL character, rather than continuing to the actual length of the string, making it much less useful than std::string. I don't like the imposition on the ...


3

I feel like the implementation of the class would be simpler if backed by a std::array<value_type , Size> instead of value_type _buffer[Size];, because then you could use the standard algorithms (aka iterators) easier, and get bounds checking in debug builds (at least in MSVC). Initializing the buffer via : _buffer{} is unnecessarily slowing you down ...


2

Overall Please fix the formatting. It's hard to find the public/private sections that way this is formatted. A fundamental miss of your dynamic array is that objects are not correctly created or destroyed. You use malloc() and realloc() to allocate memory. But these functions do not call the constructors on class type objects. Thus the memory is not ...


1

Since you're using malloc, realloc, and free for memory management, your class can only be instantiated with POD classes. Any class with a constructor, destructor, or copy assignment operator may not work with your myVector class because these special functions will not be called. The copy constructor is wrong. Since it uses copy assignment, and the copy ...


0

FTBFS This code doesn't compile here (GCC 9.2, -std=c++2a): 29935.cpp:24:64: error: ‘class std::basic_ostream<char>’ has no member named ‘str’ 24 | std::string replacement_string{(std::ostringstream{} << val).str()}; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ I had to expand that to keep a reference to the ...


1

writeVoxelAsSTL takes unsigned arguments, but it seems like the native type is actually a long. Could it take longs instead? For example, unsigned(2^31) looks like it would not be a valid value since it would overflow into -1 upon conversion. You could take an ostream& argument instead so the code isn't coupled to files. You could factor out the bools ...


-2

Handle the Aces! (That's my only problem, I got a 22 at start)


2

Quite a bit of code to look at. This is not a complete review, but I did two simple things, which may prompt thought / improvements: I ran a static analyser over your code (clang-tidy V9). The output is below. It is pointing many of the stylistic things I would say too. And it highlights some actual issues. I added a main() method and i tried to use your ...


Top 50 recent answers are included