Getter のインターフェイスのパターン

  1. info_t GetInfo() const
  2. const info_t* GetInfo() const
  3. const info_t& GetInfo() const
  4. void GetInfo(info_t* info) const
  5. void GetInfo(info_t& info) const
  • GetInfo()->a, GetInfo.a といった利便性が高い方が良い場合もある
  • サンプリングとしての側面を意識させて GetInfo()->a, GetInfo.a を禁止すべき場合もある
    • マルチスレッドの場合などその瞬間の情報をコピーして参照する