#include <iostream>
#include <vector>

namespace problem {
class storage {
    struct data_base {};
    
    template <class K> 
    struct data: data_base {
        data(const K& v): value_(v) {}
        K value_;
    };
    
    typedef std::vector<data_base*> container_type;
    
public:
    ~storage() {
        while(!this->VData.empty()) {
            delete this->VData.back();
            this->VData.pop_back();
        }
    }
    template <class P>
    inline void push(P v) {
        this->VData.push_back(new data<P>(v));
    }
    template <class P>
    P &get(int i) { 
        return static_cast<data<P>*>(this->VData[i])->value_; 
    }
private:
    container_type VData;
};
}

int main() {
    problem::storage testStorage;
    testStorage.push(256);
    testStorage.push(3.4);

    std::cout << testStorage.get<int>(0) << std::endl;
    std::cout << testStorage.get<double>(1) << std::endl;
}