Похожие чаты

What is the difference between: vector<int> const& v and const vector<int> &v as parameters

of a functions?

12 ответов

21 просмотр

https://isocpp.org/wiki/faq/const-correctness

Brian- Автор вопроса
Ghasem Ramezani
https://isocpp.org/wiki/faq/const-correctness

😂, Too tired to RTFM, any short normal explanation?

Brian
😂, Too tired to RTFM, any short normal explanation...

https://isocpp.org/wiki/faq/const-correctness#const-ptr-vs-ptr-const

Brian- Автор вопроса

Yup this is what I thought, but in cppcon, there is talk that one can't call vector<int>::begin() on vector<int> const &, So how did T const & make T const? 🧐

Brian
Yup this is what I thought, but in cppcon, there i...

std::vector<int> const& and const std::vector<int> & is the same.

No difference in this case, bacause it's a reference.

Brian- Автор вопроса
Pavel
No difference in this case, bacause it's a referen...

So in pointers is the only time it applies?

because reference can't change where they "point" to

Brian- Автор вопроса
Brian
😂 then what's the fucking point of a T const & ?

Someone once decided, let's not decide for people where they want to put const :D

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

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

А как старый хаскел с новым стыковать ? потому как тут работает https://play.haskell.org/saved/C3xpMzcd, а вот тут https://stepik.org/lesson/7602/step/9?unit=1473 нет ошибка C...
Fedor
131
Вопрос я правильно понимаю что в коде newtype ArrowMap k v = ArrowMap { getArrowMap :: k -> Maybe v } getArrowMap есть функция типа k -> Maybe v, если да, то не понимаю задач...
Fedor
61
I am honored to report that all the deliverables for the BCHFAQ Flipstarter Phase 1 have been completed. I appreciate the opportunity I've had to put all this together using t...
fixthetracking
14
Is there any new news from Kadena? The price is very suppressed.
HAKAN TECİMEN
27
Как Вы считаете нормально ли в двадцатых годах 21 века в ВУЗах Российской Федерации обучать студентов работе с TASM? Не слишком ли это "архаично"? (Если оффтоп или флейм для э...
Spiker01
52
Продолжая диалог про свифт в проде – сейчас возник вопрос в активном наборе бекендеров. В основном в нашей компании мы фанаты Java Spring и полностью ей довольны. Однако найм ...
Guseyn
27
Hello everyone! I have CHZ coins in the BEP2 network, what should I do to change the network, since Binance stops entering coins in this network???
Ts. Ts.
22
Комрады, хотел уточнить. Проперть в OnDestroy юнита-хозяина по-прежнему доступна? И еще уточнение: finalization юнита наступает раньше или позже OnDestroy?
Ed Doc
48
Читаю сейчас [нет, уже больше не читаю!] курсовую о Булгакове, написанную, похоже, с помощью ChatGPT. Это удивительный психоделический опыт. Текст в основном написан в стиле б...
✨ Uni [🌊 В отпуске]
1
Tell me how to solve this problem: I transferred the xtz token to the “trust W” wallet, I wanted to do staking. but as a result, the coins just lie on the wallet (they are not...
German
13
Карта сайта