Skip to content

Instantly share code, notes, and snippets.

@plasticbox
Created June 16, 2016 06:08
Show Gist options
  • Select an option

  • Save plasticbox/0fcacc65b91d38842eb25dbe96140d84 to your computer and use it in GitHub Desktop.

Select an option

Save plasticbox/0fcacc65b91d38842eb25dbe96140d84 to your computer and use it in GitHub Desktop.
FixedVector C++
template<typename T, unsigned int maxSize>
class FixedVector : public std::vector<T>
{
public:
FixedVector() { _maxSize = maxSize; }
bool push_back(const T& elem)
{
if(_maxSize > size())
{
std::vector<T>::push_back(elem);
return true;
}
return false;
}
private:
unsigned int _maxSize;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment