For example, this is my implementation of vector:
template<typename T, /*...*/>
class List {
private:
/*...*/
int count;
int capacity;
public:
/*constexpr int Count() noexcept {
return count;
}*/
/*constexpr int Capacity() noexcept {
return capacity;
}*/
const int& Count = count;
const int& Capacity = capacity;
/*...*/
}
Because these 2 methods just return a private field, ensuring that unable to be changed, and there's no other operations, checks or exceptions in function. Could I take the replace in this situation?
One of the disadvantages I've noticed is that 16 bytes is added for List due to the 2 references(pointers). Could it be optimized?