|
|
|
Linux map.find( ......
|
|||
|---|---|---|---|
|
#18+
Помощь ваша нужна, господа монстры C++; OS SuSE 10 Когда задаю имеющийся ключ все путём, когда ключа нет в мэпе, на map1.find(mm) : "bin/sh: line 1: 13182 Segmentation fault ./hell" где я дурак, а где он?? #ifdef HAVE_CONFIG_H #include <config.h> #endif //#include <iostream> #include <cstdlib> #include <string> //#include <list> #include <map> //#include <hash_map> using namespace std; template< typename Key, typename Value > struct application_map { typedef std::map<Key,Value> map; }; struct bde { string a; bool operator()(const bde& s1, const bde& s2) const { return s1.a < s2.a; } bool operator==(const bde& s1) const { return s1.a == a; } bool operator!=(const bde& s1) const { return s1.a != a; } }; typedef map<bde,string, bde> group_map; int main(int argc, char *argv[]) { group_map map1; bde mm,mm2; map1[mm]="mama"; mm.a="c"; map1[mm]="papa"; mm.a="3"; map1[mm]="deda"; mm.a="4"; map1[mm]="baba"; try { mm.a="3"; //ok - mm.a="3"; Segmentation fault - mm.a="33"; if ( map1.find(mm) != NULL ) cout << "i=" << (*map1.find(mm)).first.a << endl; } catch (std::exception& e){ cout << e.what() << endl;} return EXIT_SUCCESS; } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.02.2006, 16:48 |
|
||
|
Linux map.find( ......
|
|||
|---|---|---|---|
|
#18+
упс template< typename Key, typename Value > struct application_map { typedef std::map<Key,Value> map; }; лишнее) сори ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.02.2006, 16:51 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=33562820&tid=2031887]: |
0ms |
get settings: |
7ms |
get forum list: |
18ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
187ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
47ms |
get tp. blocked users: |
1ms |
| others: | 232ms |
| total: | 512ms |

| 0 / 0 |
