OS разработка: Ubuntu 24.04 lts.
my Target OS: vxworks 7
Язык: C ++ 17
< /p>
код: < /p>
Код: Выделить всё
struct DemoStruct
{
int a;
float b;
std::string data;
bool operator>(const DemoStruct& object) const //Check if greater
{
return this->a > object.a;
}
};
std::vector container;
std::priority_queue
<
DemoStruct,
std::vector,
std::greater
>
mReceiveDataQueue {
{}, std::move(this->container)
};
while (i < 10)
{
DemoStruct d = {
.a = 10 - i,
.b = i * 2.0f,
.data = "Hello, World!!!"; //Will mostly hold data with 85 characters
};
mReceiveDataQueue.push(d); //or mReceiveDataQueue.push(std::move(d))
}
< /code>
Что я хочу понять, поможет ли зарезервировать память? Из того, что я понимаю, каждый раз в конструкторе петли Подробнее здесь: https://stackoverflow.com/questions/794 ... rity-queue
Мобильная версия