Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

The ONLY C keyword with no C++ equivalent

C++

C programming

restrict keyword

restrict pointer

Автор: mCoding

Загружено: 14 авг. 2021 г.

Просмотров: 282 762 просмотра

Описание:

C has "restrict" but C++ does not.

The restrict keyword in C is the only keyword that has no analogue in C++. The keyword promises to the compiler that objects accessible through the pointer will not be accessed (either read or written to) through any other means than through the restrict pointer. This promise to the compiler allows more potential optimizations, including removing redundant reads and potentially allowing automatic vectorization, which can lead to smaller and faster code. However, if you use it incorrectly, restrict can be the source of some seriously hard to find bugs because they may only appear at high optimization levels and not in your testing or debugging builds. Major C++ compilers do support restrict in a non-standardized way though, so if you are willing to write code that is specific to your compiler, then you may still be able to take advantage of restrict even though it is not part of standard C++.

Erratum: In the fib_upto_n example the check for n==0 should go before the write to dst[0], and the check for n==1 should go before the write to dst[1], it is fixed in the GitHub link. I'm very confused why I ever wrote it that way, but that's what I get for not writing tests :). This did not affect anything in the video because I was using n=10.

― mCoding with James Murphy (https://mcoding.io)

Source code: https://github.com/mCodingLLC/VideosS...
Compiler explorer: https://godbolt.org/z/4EzvTGcfo
restrict keyword: https://en.cppreference.com/w/c/langu...
StackOverflow on restrict: https://stackoverflow.com/questions/7...

SUPPORT ME ⭐
---------------------------------------------------
Patreon:   / mcoding  
Paypal: https://www.paypal.com/donate/?hosted...
Other donations: https://mcoding.io/donate

Top patrons and donors:
Laura M, Jameson, John M, Pieter G, Vahnekie, Sigmanificient

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord:   / discord  
Github: https://github.com/mCodingLLC/
Reddit:   / mcoding  
Facebook:   / james.mcoding  

CHAPTERS
---------------------------------------------------
0:00 Intro
0:58 Restrict explanation
3:42 Vector add example
6:28 Correctness fib example
9:06 Best practices, memcpy and memmove
10:21 Restrict in C++
12:41 Thanks

The ONLY C keyword with no C++ equivalent

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

C++ Sudoku Solver in 7 minutes using Recursive Backtracking

C++ Sudoku Solver in 7 minutes using Recursive Backtracking

Return Value Optimization and Copy Elision in C++

Return Value Optimization and Copy Elision in C++

31 nooby C++ habits you need to ditch

31 nooby C++ habits you need to ditch

Advanced C: The UB and optimizations that trick good programmers.

Advanced C: The UB and optimizations that trick good programmers.

"BEST C++ CODE ever written" // Code Review

The

The "vibe coding" mind virus explained…

C++ cache locality and branch predictability

C++ cache locality and branch predictability

all of a sudden, everything becomes alright.

all of a sudden, everything becomes alright.

study with me - 30 minute, 10 minute break, with lofi focus music - 3.5 -hour pomodoro

study with me - 30 minute, 10 minute break, with lofi focus music - 3.5 -hour pomodoro

why do void* pointers even exist?

why do void* pointers even exist?

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]