const Data& operator[](const String& key) const { if (isHash()) { const auto it = hash_.find(key); if (it == hash_.end()) { return kNilData; } return it->second; } else if (isDrop()) { return (*drop_)[key]; } else { throw std::runtime_error("[] requires a hash or drop"); } }
PieceType pieceTypeFromOrDropped() const { return (isDrop() ? pieceTypeDropped() : pieceTypeFrom()); }
std::shared_ptr<Drop> drop() const { if (!isDrop()) { throw std::runtime_error("drop() requires a drop"); } return drop_; }
// 移動した後の駒の種類 PieceType pieceTypeTo() const { if(isDrop()) { return pieceTypeDropped(); } return pieceTypeTo(pieceTypeFrom()); }