Created
June 1, 2014 05:08
-
-
Save mryoshio/8df1158814802cafb9e7 to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#include <string> | |
#include <vector> | |
/* | |
Usage: g++ -std=c++11 foo.cpp | |
*/ | |
using namespace std; | |
struct Entry { | |
string name; | |
int number; | |
}; | |
template<typename T> | |
class Vec : public std::vector<T> { | |
public: | |
using vector<T>::vector; | |
T& operator[](int i) { return vector<T>::at(i); } | |
}; | |
int main() { | |
Vec<Entry> v = { | |
{"Taro", 1111}, | |
{"Hanako", 2222}, | |
{"Saburo", 3333} | |
}; | |
v[4] = {"Shirou", 444}; | |
// v.at(4) = {"Shirou", 444}; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment