powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / C++ [игнор отключен] [закрыт для гостей] / Linux map.find( ......
3 сообщений из 3, страница 1 из 1
Linux map.find( ......
    #33562816
Fenriz
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Помощь ваша нужна, господа монстры 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;
}
...
Рейтинг: 0 / 0
Linux map.find( ......
    #33562820
Fenriz
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
упс
template< typename Key, typename Value > struct application_map
{
typedef std::map<Key,Value> map;
};

лишнее) сори
...
Рейтинг: 0 / 0
Linux map.find( ......
    #33562874
Fenriz
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
сам разобрался, томознял
map1.find(mm) != map1.end()
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / C++ [игнор отключен] [закрыт для гостей] / Linux map.find( ......
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]