質問
ようにしているジャンプを通じて一部のタガを整理しデータ"と言われています。私を含め、簡体字のコードを示して私が痛みを発します。
利用できないもの。を使用している最新バージョンはg++cygwin.
#include <iostream>
#include <map>
using namespace std;
int main () {
map< int,int > genmap;
map< int,int >::iterator genmapit;
map< map<int,int>::iterator,int > itermap;
// insert something into genmap
genmap.insert (make_pair(1,500) );
// find and return iterator.
genmapit=genmap.find(1);
// insert the iterator/int into itermap. Dies on each of the following 3 versions of this line.
//itermap[genmapit] = 600; // crash
//itermap.insert ( pair< map<int,int>::iterator,int >(genmapit,600) ); // crash
itermap.insert ( make_pair(genmapit,600) ); // crash
return 0;
}
でき、1簡易地図序で繰り返し処理する反復子をマップすると別の地図ることが最初の引数としての反復子の最初のマップ。
ですからこの:なぜすることはできないのでしょうかを入れて反復子にな地図か? ることができまし序で繰り返し処理する反復子としての第二引数に使います。しかし、上記を提供す:
$ make
g++ -c -o main.o main.cpp
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_function.h: In member fun
ction `bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp =
std::_Rb_tree_iterator<std::pair<const int, int> >]':
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_tree.h:871: instantiate
d from `std::pair<typename std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _All
oc>::iterator, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::i
nsert_unique(const _Val&) [with _Key = std::_Rb_tree_iterator<std::pair<const in
t, int> >, _Val = std::pair<const std::_Rb_tree_iterator<std::pair<const int, in
t> >, int>, _KeyOfValue = std::_Select1st<std::pair<const std::_Rb_tree_iterator
<std::pair<const int, int> >, int> >, _Compare = std::less<std::_Rb_tree_iterato
r<std::pair<const int, int> > >, _Alloc = std::allocator<std::pair<const std::_R
b_tree_iterator<std::pair<const int, int> >, int> >]'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_map.h:360: instantiated
from `std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_
Select1st<std::pair<const _Key, _Tp> >, _Compare, _Alloc>::iterator, bool> std::
map<_Key, _Tp, _Compare, _Alloc>::insert(const std::pair<const _Key, _Tp>&) [wit
h _Key = std::_Rb_tree_iterator<std::pair<const int, int> >, _Tp = int, _Compare
= std::less<std::_Rb_tree_iterator<std::pair<const int, int> > >, _Alloc = std:
:allocator<std::pair<const std::_Rb_tree_iterator<std::pair<const int, int> >, i
nt> >]'
main.cpp:23: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_function.h:227: error: no
match for 'operator<' in '__x < __y'
make: *** [main.o] Error 1
"インスタンスを生成はこちらから"かなウェブサイトをデザイン検索を与えてくれていない情報です。
はSTL:地図だけですることを認めない。まrecode私のアプリこの動することもできますが非常に非効率ということです。ある他の種類のポインタで、マップ要素が使えますか。
おります。
解決
できないことが std::map
反復子はランダムアクセスの反復子ではないとの比較 <
.
代わりに、利用のポインタのvalue_typeの地図地図として鍵となる。
他のヒント
お読み方を学ぶこのエラーメッセージが返されます。特に見られる"というメッセージの後の冗長説明 場所 エラーの起こった:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_function.h:227: error: no match for 'operator<' in '__x < __y'
地図を反復子がないのとは比較によるオペレーターの地図利用によるデフォルトです。
と思いを提供する事ができ比較機能数を比較しながペアによって指定された反復子は、反復子自身にはお客さまのご要望に合わせたカに比べて有意義です。
struct CompareIterator
{
template <class FirstIter, class SecondIter>
bool operator()(FirstIter lhv, SecondIter rhv) const
{
return *lhv < *rhv;
}
};
//usage with map:
map< map<int,int>::iterator,int, CompareIterator > itermap;
std::pair
定義 operator<
.また利用している反復子の種類、かまっていく可能性も否定できな種類の異なる(iterator
や const_iterator
)
map<Key, Value>
の map
iterator
として重要な要素別 map
はできませんので map
期待 operator <
に定義されることによりデフォルトの鍵となる。の場合 Key
(この場合において map iterator
)が定義されていないその合格する必要があり、元として、述語機能を提供するとの比較の地図は、iterator).