New answers tagged


We can use the standard library for equality comparison: #include <algorithm> constexpr bool operator==(const SmallVector &other) const noexcept { return std::equal(begin(), end(), other.begin(), other.end()); }


Here is my unpopular opinion: This class has no reason to exist and you should use std::array instead which does what you need. If you need it to be compatible with std:: vector for template meta programming, you can just add a thin wrapper on top or use SFINAE to call reserve only if it exists.


Here's my suggestions: Design Calling the constructors and destructors at the correct time with constexpr is indeed nontrivial, but disrespect object lifetime != POD. Your implementation is conceptually fine with some non-POD types. Maybe "trivial" is what you are looking for. You are missing a lot of functionality. Users may want to use them, so you ...


Welcome to C++! This code review focuses on writing idiomatic C++ code. #include<iostream> #include<cstdlib> #include<ctime> #include<cmath> #include <tgmath.h> Don't #include <tgmath.h> because it is deprecated. It just includes #include <complex> and #include <cmath>. In this case, you do not use complex ...


Welcome to C++. It seems that you are more or less trying to write C code rather than C++ though. Lets have a look at what you can improve: Never do using namespace std; It is a terrible practise that gets you into trouble really fast. std:: is not that hard to type so get in the habit early. If you have compile time constants use them via constexpr Your ...

Top 50 recent answers are included