13typedef std::string string;
18class vector :
public std::vector<T>
21 using std::vector<T>::vector;
22 using std::vector<T>::operator=;
27class vector<bool> :
public std::vector<char>
30 using std::vector<
char>::vector;
31 void push_back(
bool value) { std::vector<char>::push_back(value ? 1 : 0); }
32 void emplace_back() { std::vector<char>::emplace_back(0); }
33 bool& back() {
return reinterpret_cast<bool&
>(std::vector<char>::back()); }
34 const bool& back()
const {
return reinterpret_cast<const bool&
>(std::vector<char>::back()); }
45 optional(
const optional& other)
46 : _data(other._data ? new T(*other._data) : nullptr)
50 optional(optional&& other)
53 other._data =
nullptr;
56 optional(
const T& other)
62 : _data(new T(
std::move(other)))
71 optional& operator=(
const optional& other)
76 *_data = *other._data;
78 _data =
new T(*other._data);
88 optional& operator=(optional&& other)
93 other._data =
nullptr;
97 optional& operator=(
const T& other)
102 _data =
new T(other);
106 optional& operator=(T&& other)
109 *_data = std::move(other);
111 _data =
new T(std::move(other));
115 operator bool()
const {
return _data !=
nullptr; }
117 T& operator*() {
return *_data; }
118 const T& operator*()
const {
return *_data; }
119 T* operator->() {
return _data; }
120 const T* operator->()
const {
return _data; }
122 friend bool operator==(
const optional& lh,
const T& rh) {
return lh._data && *lh._data == rh; }
123 friend bool operator!=(
const optional& lh,
const T& rh) {
return !lh._data || *lh._data != rh; }
124 friend bool operator==(
const T& lh,
const optional& rh) {
return rh._data && lh == rh._data; }
125 friend bool operator!=(
const T& lh,
const optional& rh) {
return !rh._data || lh != rh._data; }
126 friend bool operator==(
const optional& lh,
const optional& rh) {
return lh._data == rh._data || (lh._data && rh._data && *lh._data == *rh._data); }
127 friend bool operator!=(
const optional& lh,
const optional& rh) {
return lh._data != rh._data && (!lh._data || !rh._data || *lh._data != *rh._data); }
146 operator T()
const {
return _value; }
147 operator T&() {
return _value; }
149 base& operator=(T value)