Test 1 Luxoft
Test 1 Luxoft
comment in the code, and make sure at least one of the variable is named "varOcg".
c static vector
capacity()
push_back()
size()
subscript operator [ ]
Static_vector instance must pass a compile time check for set capacity.
#include <cstddef>
#include <stdexcept>
#include <type_traits>
public:
constexpr static_vector() : size_(0) {}
data_[size_++] = value;
}
return data_[index];
}
// add const op []
const T& operator[](std::size_t index) const
{
if(index >=size_)
{
throw std::out_of_range("Index out of bounds");
}
return data_[index];
}
private:
T data_[Capacity]{};
std::size_t size_;
};
#endif