こんばんは(あなたが今どこにいるかによって異なります)。ソートされたセットの stl と少し混乱しています...カスタムクラスのポインターをセットに保存したいのですが、ポインターのサイズだけでなく、独自の基準でソートしたいと考えています。
誰でもこれを行う方法を知っ_Stack Overflow日本語サイト
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
誰でもこれを行う方法を知っ
誰でもこれを行う方法を知っていますか? operator<(const foo &*rhs, const foo &*lhs){..}; のようにはできないので、
助言がありますか?よろしくお願いします。
txt ファイルの末尾にある余分な '\n' を削除したいと思います。c/c++ でこのジョブを実行するために使用できる関数はどれですか。
ありがとう
std::setの2番目のテンプレートパラメータは、比較に使用するメソッドです。したがって、次のようなことができます。
std::set
struct dereference_compare { template <typename T> bool operator()(const T* pX, const T* pY) const { return *pX < *pY; } }; typedef std::set<T*, dereference_compare> set_type;