Created
June 16, 2016 06:08
-
-
Save plasticbox/0fcacc65b91d38842eb25dbe96140d84 to your computer and use it in GitHub Desktop.
FixedVector C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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