Похожие чаты

Obj& obj::operator=(const obj& other) { data.clear();

for (auto row_it = other.data.begin(); row_it != other.data.end(); ++row_it)
{
// code
}
}


Is this one of the situations where using auto is necessary? I see most websites have used auto. My second question is what's auto deduced to ? Can I write it myself too ?

5 ответов

9 просмотров

auto it's some compile time thing when type deducing automatically

It is not necessary, but this is one of the cases when auto is approved in most coding standards (even in those that avoid using auto). Basically because the real type can be quite verbose. You can replace it with the real type, which is an iterator type of your container. E.g. if data is std::vector<int> then the type will likely be std::vector<int>::iterator

Sahand-🏔️ Автор вопроса
Pavel
It is not necessary, but this is one of the cases ...

Thanks. (However the iterator must be const : std::vector<int>::const_iterator)

Sahand-🏔️ Автор вопроса
Pavel
Yeah, that's why "likely" :D

Lol i didn't notice it.

Похожие вопросы

Обсуждают сегодня

а зачем этот вопрос для удаления из чата?
Mёdkinson Medvezhkin
63
Добрый день. Хочу сделать отрисовку по команде на панели. Почему-то рисуется только при втором вызове. С чем может быть связано, не подскажете? procedure TForm1.FormDblClick(...
Kirill Filippenok
20
Any dog on Fantom ?
Bitcoin Magic
15
Всем доброго дня! Подскажите может кто использовал связку Pagebuilder + Clientsetting. Сами параметры с типом pagebuilder в модуле Clientsetting работают нормально, можно такж...
Александр Добриков
11
А почему в си некоторые вещи работают с двойными кавычками некоторые с одинарными? Нельзя было все сделать с одними или чтоб работало с разными? например чтоб выводить строки ...
.
15
using next image component with s3 image: "url" parameter is valid but upstream response is invalid code: <Image fill src={s...
Fasil
3
Всем привет! Нужен совет от опытных. Переношу свой проект с Делфи 10.2 Токио на Лазарус 3.2 установленный через инсталлятор fpcupdeluxe-x86_64-win64. При импортировании проект...
Дмитрий Завгородний
7
Добрый день Как поставить vscode из флэтпака как дефолтный редактор в filezilla?
Daniel
16
Tax his land, Tax his bed, Tax the table At which he's fed. Tax his work, Tax his pay, He works for peanuts Anyway! Tax his cow, Tax his goat, Tax his pants, Tax his coat....
Forge
3
https://youtu.be/p-shHtvUAts?si=qiD_u_55w2sKDRju Raoul Paul talks with David Packham of chintai.io 🚀 Exciting insights from Chintai CEO @GunnisonCap in our latest interview! ...
NovaCrypto MW3S
1
Карта сайта